WordPress on Nginx

Running WordPress on server with Nginx is not a problem. However getting “pretty” permalinks can be a challenge.

What you need to do, is to add an extra directive to your vhost setting for the domain you host your blog on. Depending on how you’ve set up your blog the way varies. If you’ve done it the hard core way in terminal using wget, tar and vi – you probably already know what to do…

If you are using software like ISPConfig, you need to edit the nginx Directives part under options for your vhost.

If you don’t use any software to manage your server, you have to manually edit your vhost file. On a Ubuntu/Debian box this is located in /etc/nginx/sites-available/.

Add the following directive to that file. If you are unfamiliar with editing vhost files, just place it at the bottom.

try_files $uri $uri/ /index.php?$args;

If you have your WordPress install under a folder like blog, you have to make sure the directive is placed under that location, like this;

location /blog/ {

try_files $uri $uri/ /index.php?$args;


}

Remember to either reload or restart the nginx service for the changes to take effect.

Now you can change the permalinks to your heart’s content!

 

One Reply to “WordPress on Nginx”

Leave a Reply