nginx and WordPress

extras

august 17


I just moved my weblog from a shared-hosting provider because it was getting laggy into my private Xen VPS at Linode (shame-less referral link is included :) ). I decided to move away from Apache due to its heavy memory usage, and use Nginx instead. nginx (pronounced “engine X”) is a lightweight, high-performance Web server/reverse proxy and e-mail (IMAP/POP3) proxy, licensed under a BSD-like license. Its memory footprint is much less than Apache and the performance is much better as well.

I’ve setup nginx & PHP running as fast-cgi following this guide from the Linode community documentation (an excellent resource I might say).

In order to get it working with the WordPress, I needed to translate mod rewrite rules to work with nginx, so my fancy permalinks would work. I used the following config for that:

location / {
root /home/websites/andreas.louca.org/public_html;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
}

The try_files directive will check if the file exists first. If it exists (like an image file) it will serve that directly. If it doesn’t, it will pass that as an argument to WordPress’ index.php. As simple as it gets!

Hope this helps someone!

Your thoughts please

Your Information

No personal information provided here will be used for unlawful purposes and your email will not be displayed on the web blog.
Website is used for linking your name.
Review comment policy before posting.
* = required
Thanks!

Thought-dump here