Web server

Nginx configuration for wordpress

Simple nginx configuration to launch wordpress site

server {
        server_name yourdomain.com;
        root /var/www/wp; # path to wordpress
        index index.php;

        gzip on; # enable gzip compression
        gzip_disable "msie6";
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

        location ~ /\. {
                deny all; # disable hidden files
        }

        location ~* /(?:uploads|files)/.*\.php$ {
                deny all; # disable uploaded scripts
        }

        location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                access_log off;
                log_not_found off;
                expires max; # static caching
        }

        location / {
                try_files $uri $uri/ /index.php?$args; # permalinks
        }

        location ~ \.php$ {
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}

Leave a Reply

Your email address will not be published. Required fields are marked *