Home > Blog > Nginx and Wordpress

Nginx and Wordpress

My Nginx and Wordpress configuration on Debian Linux 5 (Lenny). This has Nginx as the Web server using the fastcgi module to talk to php-cgi processes that run Wordpress with pretty URLs.

The virtual private server I installed this on (from John Companies) has a 256 megabyte slice, so I figured a regular Apache + mod_php setup might be in trouble seeing as one of the sites I am running gets several thousand visits a day. Up to now I have always used Apache with mod_php to run Wordpress, and anyway it is fun to learn how unfamiliar software works (Lotus Notes excepted).

On a side note, SysV run-levels and /etc/rcX.d directories are needlessly clever. sysv-rc-conf makes editing those easy.

server {
    listen   80;
    server_name  example.com;

    root   /home/david/example.com;
    index  index.php index.html index.htm;
    error_page   500 502 503 504  /50x.html;

    location / {

    }

    location = /50x.html {
        root   /var/www/nginx-default;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    location ~ /\.ht {
        deny  all;
    }

    location /b/ {
        if (!-e $request_filename) {
            rewrite ^(.+)$ /b/index.php?q=$1 last;
        }
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

# Rewrite www.example.com to example.com
server {
    listen 80;
    server_name www.example.com;
    rewrite ^ http://example.com$request_uri?;
}

This configuration is for Wordpress installed under http://example.com/b/ on my server.

david , ,

  1. nct
    May 28th, 2010 at 04:24 | #1

    this is a very strange blog. like jibberish in an ee cummings geeking-out sort of way …

  2. May 28th, 2010 at 11:51 | #2

    It lacks poetry though. What does the c stand for nct?

  3. nct
    June 11th, 2010 at 04:09 | #3

    the same as wt – middle name. sorry i don’t mean to intrude on what is obviously a very serious blog with real technological purpose / dissemination intent …! stumbled across it and had to say hello!

  4. June 11th, 2010 at 11:01 | #4

    You just doubled the readership nct. You could e-mail me hello! david@gasmark6.com

  1. No trackbacks yet.