CPU: 1 x 2GHz
HDD: 10Gb
RAM: 512Mb
OS: Debian 8 x64
apt-get install nginx
# , user www-data www-data; # auto worker_processes auto; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { # worker_connections 1024; # ( FreeBSD kqueue) use epoll; # multi_accept on; } http { # mime- - include /etc/nginx/mime.types; default_type application/octet-stream; # nginx server_tokens off; # sendfile read+write sendfile on; # , sendfile(). sendfile_max_chunk 128k; # tcp_nopush on; tcp_nodelay on; # reset_timedout_connection on; # client_header_timeout 3; client_body_timeout 5; # , 3 send_timeout 3; # client_header_buffer_size 2k; client_body_buffer_size 256k; # client_max_body_size 12m; # access_log off; # include /etc/nginx/conf.d/*.conf; }
server { # 81 listen 127.0.0.1:81; # root /var/www/site.ru/public_html; index index.php; # gzip- . . 9 . , text/plain, 1 , CPU gzip on; gzip_comp_level 9; gzip_min_length 512; gzip_buffers 8 64k; gzip_types text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml; gzip_proxied any; # server_name site.ru www.site.ru; # location ~ /\. { deny all; } # location ~* /(?:uploads|files)/.*\.php$ { deny all; } # URI location / { try_files $uri $uri/ /index.php?$args; } # */wp-admin rewrite /wp-admin$ $scheme://$host$uri/ permanent; location ~ \.php$ { # 404 , WordPress try_files $uri =404; # php FPM include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/var/run/php5-fpm.sock; } }
server { # HTTPS listen REAL_IP:80; server_name site.ru www.site.ru; return 301 https://$server_name$request_uri; } server { listen 93.170.105.102:443 ssl; server_name site.ru www.site.ru; # Keep-Alive keepalive_timeout 60 60; # . , text/plain, , . , CPU . gzip on; gzip_comp_level 1; gzip_min_length 512; gzip_buffers 8 64k; gzip_types text/plain; gzip_proxied any; # , ssl_prefer_server_ciphers on; # TLS 2 ssl_session_cache shared:TLS:2m; ssl_session_timeout 2m; # , ssl_certificate /etc/ssl/combined.crt; # ssl_certificate_key /etc/ssl/3_site.ru.key; # - ssl_dhparam /etc/ssl/dh2048.pem; # ssl_protocols TLSv1.2 TLSv1.1 TLSv1; # , forward secrecy ssl_ciphers EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA512:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:ECDH+AESGCM:ECDH+AES256:DH+AESGCM:DH+AES256:RSA+AESGCM:!aNULL:!eNULL:!LOW:!RC4:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS; # Strict-Transport-Secutiry add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains'; location / { # Varnish proxy_pass http://127.0.0.1:6081/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Port 443; } }
service nginx reload
apt-get install varnish
DAEMON_OPTS="-a :6081 \ -T 127.0.0.1:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ -s malloc,128m"
# , VCL 4 vcl 4.0; # backend default { .host = "127.0.0.1"; .port = "81"; } # IP/, PURGE- acl purge { "localhost"; "127.0.0.1"; } # sub vcl_recv { # if (req.method == "PURGE") { # , if (!client.ip ~ purge) { return(synth(405, "This IP is not allowed to send PURGE requests.")); } return (purge); } # POST- Basic- if (req.http.Authorization || req.method == "POST") { return (pass); } # if (req.url ~ "wp-(login|admin)" || req.url ~ "preview=true") { return (pass); } # sitemap robots, sitemap Google XML Sitemaps if (req.url ~ "sitemap" || req.url ~ "robots") { return (pass); } # cookies, "has_js" "__*", CloudFlare Google Analytics, Varnish , cookies. set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", ""); # ";" cookies, set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", ""); # Quant Capital cookies ( ) set req.http.Cookie = regsuball(req.http.Cookie, "__qc.=[^;]+(; )?", ""); # wp-settings-1 cookie set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", ""); # wp-settings-time-1 cookie set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", ""); # wp test cookie set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", ""); # cookie, ( ) if (req.http.cookie ~ "^ *$") { unset req.http.cookie; } # cookies, if (req.url ~ "\.(css|js|png|gif|jp(e)?g|swf|ico|woff|svg|htm|html)") { unset req.http.cookie; } # cookies "wordpress_" "comment_" if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") { return (pass); } # cookie , if (!req.http.cookie) { unset req.http.cookie; } # cookies, WordPress if (req.http.Authorization || req.http.Cookie) { # Not cacheable by default return (pass); } # return (hash); } sub vcl_pass { return (fetch); } sub vcl_hash { hash_data(req.url); return (lookup); } # sub vcl_backend_response { # unset beresp.http.Server; unset beresp.http.X-Powered-By; # robots sitemap if (bereq.url ~ "sitemap" || bereq.url ~ "robots") { set beresp.uncacheable = true; set beresp.ttl = 30s; return (deliver); } # , ... if (bereq.url ~ "\.(css|js|png|gif|jp(e?)g)|swf|ico|woff|svg|htm|html") { # unset beresp.http.cookie; # - set beresp.ttl = 7d; # Cache-Control Expires, , unset beresp.http.Cache-Control; set beresp.http.Cache-Control = "public, max-age=604800"; set beresp.http.Expires = now + beresp.ttl; } # if (bereq.url ~ "wp-(login|admin)" || bereq.url ~ "preview=true") { set beresp.uncacheable = true; set beresp.ttl = 30s; return (deliver); } # , if (!(bereq.url ~ "(wp-login|wp-admin|preview=true)")) { unset beresp.http.set-cookie; } # POST- Basic if ( bereq.method == "POST" || bereq.http.Authorization ) { set beresp.uncacheable = true; set beresp.ttl = 120s; return (deliver); } # if ( bereq.url ~ "\?s=" ){ set beresp.uncacheable = true; set beresp.ttl = 120s; return (deliver); } # , ! if ( beresp.status != 200 ) { set beresp.uncacheable = true; set beresp.ttl = 120s; return (deliver); } # set beresp.ttl = 1d; # TTL set beresp.grace = 30s; return (deliver); } # sub vcl_deliver { # unset resp.http.X-Powered-By; unset resp.http.Server; unset resp.http.Via; unset resp.http.X-Varnish; return (deliver); }
service varnish restart
[Unit] Description=Varnish HTTP accelerator [Service] Type=forking LimitNOFILE=131072 LimitMEMLOCK=82000 ExecStartPre=/usr/sbin/varnishd -C -f /etc/varnish/default.vcl ExecStart=/usr/sbin/varnishd -a :6081 -T 127.0.0.1:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,128m ExecReload=/usr/share/varnish/reload-vcl [Install] WantedBy=multi-user.target
systemctl daemon-reload service varnish restart
apt-get install php5-fpm php5-mysqlnd
listen = 127.0.0.1:9000
listen = /var/run/php5-fpm.sock
; pm = dynamic ; , , pm.max_spare_servers. pm.max_children = 10 ; FPM pm.start_servers = 1 ; ( ) pm.min_spare_servers = 1 ; ( , ) pm.max_spare_servers = 3 ; , , pm.max_requests = 500
upload_max_filesize = 10M post_max_size = 12M allow_url_fopen = Off
service php5-fpm reload
apt-get install mariadb-server
# key_buffer = 64M # query_cache_size = 32M # MyISAM default-storage-engine=MyISAM # InnoDB skip-innodb
service mysql restart
Source: https://habr.com/ru/post/278189/
All Articles