Optimizing WordPress with Nginx, Varnish, APC, W3 Total Cache
Идеята е ясна – оптимизация на уордпрес блога чрез varnish който работи пред nginx-a с една едничка цел – по-бързо отваряне на сайта ни.
Първо инсталираме nginx и php-fpm :
apt-get install nginx php5-fpm
Ето и примерния ни nginx.conf:
user www-data; worker_processes 12; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; worker_rlimit_nofile 8192; events { worker_connections 4096; # multi_accept on; } http { include /etc/nginx/mime.types; # include /etc/nginx/proxy.conf; include /etc/nginx/fastcgi.conf; access_log /var/log/nginx/access.log; upload_progress proxied 1m; #cache #fastcgi_cache_path /tmp/cache/fastcgi_cache levels=1:2 keys_zone=php:16m inactive=5m max_size=500m; proxy_cache_path /var/www/cache/ levels=1:2 keys_zone=алабала.нет:10m inactive=30m max_size=2g; upstream php5-fpm-sock { server 127.0.0.1:9000 weight=100 max_fails=3 fail_timeout=5; #server 127.0.0.1:9001 weight=100 max_fails=3 fail_timeout=5; #server unix:/var/run/php5-fpm.sock; } #sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; tcp_nodelay on; gzip on; gzip_disable “MSIE [1-6]\.(?!.*SV1)”; gzip_http_version 1.0; gzip_comp_level 9; gzip_proxied any; gzip_min_length 1100; gzip_buffers 16 8k; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; server_tokens on; server_name_in_redirect off; }
След това е нужно да създадем виртуален хост за сайта ни – /etc/nginx/sites-enabled/виртуален-хост.лтд