apt-get update apt-get dist-upgrade
apt-get install htop atop vsftpd exim4-base exim4-daemon-light mailutils rcconf apache2 apache2-mpm-itk nginx mysql-server-5.5 mysql-client-5.5 php5 php5-dev memcached libmysqlclient-dev apache2-utils libexpat1 ssl-cert libapache2-mod-php5 libapache2-mod-ruby php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-common php5-ming php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl make automake checkinstall gcc gzip libreadline-dev libssl-dev libncurses5-dev zlib1g-dev
useradd dapf -b /home -m -U -s /bin/false
passwd dapf
mkdir -p -m 755 /home/dapf/dapf.ru/public_html mkdir -p -m 777 /home/dapf/dapf.ru/logs mkdir -p -m 777 /home/dapf/dapf.ru/tmp chmod 755 /home chmod 755 /home/dapf chmod +t /home/dapf/dapf.ru/logs chmod +t /home/dapf/dapf.ru/tmp chown -R dapf:dapf /home/dapf
usermod -s /bin/false www-data
a2enmod ssl a2enmod rewrite a2enmod suexec a2enmod include
nano /etc/apache2/ports.conf
NameVirtualHost *:81 Listen 81
nano /etc/apache2/apache2.conf
KeepAlive Off StartServers 1 MinSpareServers 3 MaxSpareServers 6 ServerLimit 24 MaxClients 24 MaxRequestsPerChild 3000
nano /etc/apache2/sites-available/dapf.ru
<VirtualHost *:81> ServerName www.dapf.ru ServerAlias dapf.ru ServerAdmin support@dapf.ru DocumentRoot "/home/dapf/dapf.ru/public_html" <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /home/dapf/dapf.ru/public_html/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /home/dapf/dapf.ru/logs/errors.log LogLevel warn CustomLog /home/dapf/dapf.ru/logs/access.log combined AssignUserId www-data dapf php_admin_value open_basedir "/home/dapf/:." php_admin_value upload_tmp_dir "/home/dapf/dapf.ru/tmp" php_admin_value session.save_path "/home/dapf/dapf.ru/tmp" </VirtualHost>
a2ensite dapf.ru
service apache2 restart
nano /etc/nginx/nginx.conf
user www-data; worker_processes 1; pid /var/run/nginx.pid; error_log /var/log/nginx/error.log; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; # gzip_vary on; gzip_proxied any; gzip_comp_level 7; #Level Compress gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/x-javascri$ ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
nano /etc/nginx/sites-enabled/dapf.ru
server { listen 80; server_name dapf.ru www.dapf.ru; access_log /var/log/nginx.access_log; location ~* .(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|html|htm|mp3|docx|xlsx)$ { root /home/dapf/dapf.ru/public_html/; error_page 404 = @fallback; index index.html index.php; access_log off; expires 30d; } location ~ /.ht { deny all; } location / { proxy_pass http://127.0.0.1:81/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header Host $host; proxy_connect_timeout 60; proxy_send_timeout 90; proxy_read_timeout 90; proxy_redirect off; proxy_set_header Connection close; proxy_pass_header Content-Type; proxy_pass_header Content-Disposition; proxy_pass_header Content-Length; } location @fallback { proxy_pass http://127.0.0.1:81; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } }
service nginx restart
nano /etc/vsftpd.conf
listen=YES anonymous_enable=NO local_enable=YES write_enable=YES pasv_min_port=50000 pasv_max_port=60000 dirmessage_enable=YES xferlog_enable=YES file_open_mode=0644 local_umask=022 connect_from_port_20=YES ascii_upload_enable=YES ascii_download_enable=YES ftpd_banner=Welcome to our FTP service. chroot_local_user=YES allow_writeable_chroot=YES secure_chroot_dir=/var/run/vsftpd pam_service_name=vsftpd rsa_cert_file=/etc/ssl/certs/vsftpd.pem
nano /etc/pam.d/vsftpd
#auth required pam_shells.so
service vsftpd restart
echo "deb http://ftp.us.debian.org/debian jessie main contrib non-free" >> /etc/apt/sources.list aptitude update aptitude upgrade vsftpd echo "allow_writeable_chroot=YES" >> /etc/vsftpd.conf service vsftpd restart
nano /etc/mysql/my.cnf
key_buffer = 16K max_allowed_packet = 1M thread_stack = 64K table_cache = 4 sort_buffer = 64K net_buffer_length = 2K
echo "CREATE USER '_'@'localhost' IDENTIFIED BY '_'; GRANT USAGE ON * . * TO '_'@'localhost' IDENTIFIED BY '_' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; CREATE DATABASE IF NOT EXISTS _ DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; ; GRANT ALL PRIVILEGES ON _ . * TO '_'@'localhost';" | mysql --user=root --password=__ mysql
dpkg-reconfigure exim4-config
echo "test" | mail -s Test @email.com
wget https://codeload.github.com/eaccelerator/eaccelerator/legacy.tar.gz/master -O ea.tar.gz tar xvfz ea.tar.gz
cd eaccelerator-eaccelerator-42067ac phpize ./configure make make install
mkdir -p /var/cache/eaccelerator chmod 0777 /var/cache/eaccelerator
nano /etc/php5/apache2/php.ini
; eAccelerator configuration ; Note that eAccelerator may also be installed as a PHP extension or as a zend_extension ; If you are using a thread safe build of PHP you must use ; zend_extension_ts instead of zend_extension extension = "eaccelerator.so" eaccelerator.shm_size = "16" eaccelerator.cache_dir = "/var/cache/eaccelerator" eaccelerator.enable = "1" eaccelerator.optimizer = "1" eaccelerator.check_mtime = "1" eaccelerator.debug = "0" eaccelerator.filter = "" eaccelerator.shm_max = "0" eaccelerator.shm_ttl = "0" eaccelerator.shm_prune_period = "0" eaccelerator.shm_only = "0" eaccelerator.compress = "1" eaccelerator.compress_level = "9" eaccelerator.allowed_admin_path = "/var/www/eaccelerator"
sendmail_path = /usr/sbin/exim -t
; display_errors =Off log_errors=On ; disable_functions = exec,ini_get,ini_get_all,parse_ini_file,passthru,php_uname,popen,proc_open,shell_exec,show_source,system,dl, show_source, readfile, popen, cwd,getcwd ; : diskfreespace, disk_free_space, disk_total_space, eval, fileperms, fopen, opendir, phpinfo, phpversion, posix_getpwuid, posix_getgrgid, posix_uname, . ; error_reporting = E_ALL & ~ E_NOTICE
nano /etc/my.iptables.rules
*filter -A INPUT -i lo -j ACCEPT -AINPUT -d 127.0.0.0/8 -jREJECT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A OUTPUT -j ACCEPT -A INPUT -p tcp --dport 80 -j ACCEPT -A INPUT -p tcp --dport 443 -j ACCEPT -A INPUT -p tcp --dport 20 -j ACCEPT -A INPUT -p tcp --dport 21 -j ACCEPT -A INPUT -p tcp --dport 50000 -j ACCEPT -A INPUT -p tcp --dport 60000 -j ACCEPT -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7 -A INPUT -j REJECT -A FORWARD -j REJECT COMMIT
iptables-restore < /etc/my.iptables.rules iptables-save > /etc/iptables.rules
nano /etc/network/interfaces
pre-up iptables-restore < /etc/iptables.rules
Source: https://habr.com/ru/post/226971/
All Articles