WordPress NGINX configuration

I’ve been installing some wordpress sites in my new VPS running with NGINX.

Install wordpress with Nginx is not as complicated as it might seem but you have to do some configurations to increase security and to make it work with cache plugins.
As cache plugin I’ve chosen W3 total cache because the “Page Cache”, “disk:enhanced” method allows to serve static html pages of my site and it includes some other performance improvements.

I’m not going to cover all the process of installing and configuring NGINX. Here you can find some tutorials if you’re looking for that.

First of all you have to include your domain/server configuration in “/etc/nginx/sites-available”. Create a new file with this content and adapt it with your domain / routes:

As I have various wordpress installations in my server I’m going to separate the wordpress configuration in another file and use it in my different server configurations. I’ve create a new file called “wordpress.conf” in “/etc/nginx/sites-available” (file is commented to explain the different options)

Now, you have to make a symbolic link of the first file that you have created into “/etc/nginx/sites-enabled” and restart nginx.
After that you can install wordpress normally. Once installed, you want to uncomment the line 59 of the “wordpress.conf” file ( location ~ /(\.|wp-config.php|readme.html|license.txt) { deny all; } ) to disallow the access to the config.php file, the readme and the license.

For the W3 Total Cache plugin, you can enable the page Cache as “disk:enhanced” to serve the cached pages of your site. You can also enable minify or any other option (Object and Database Cache, CDN … etc). “Browser cache” is not really necessary because NGINX is going to take care of it.

And that’s all 🙂 Any comment or improvements are more than welcome.


Go to the Homepage → ← Go back



No comments yet. Why not add one below?

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.