Need Help Configuring Nginx to run Wordpress

mike mike503 at
Fri Apr 25 11:43:52 MSD 2008

I posted mine.

user www-data www-data;

worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;

working_directory /var/run;

error_log  /var/log/nginx/error.log debug;

pid        /var/run/;

events {
    worker_connections  1024;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stre
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    client_max_body_size 100m; # More if you need up upload files
larger than 50mb
    client_header_buffer_size 8k;
    large_client_header_buffers 12 6k;
    keepalive_timeout  5;

    server_tokens off;
    server_names_hash_max_size 4096;
    server_names_hash_bucket_size 128;
    server {
       listen 80;
       index index.php index.html;
       root /home/mike/web/;
       location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$ {
          expires 30d;
       location ~ .php$ {
           include /etc/nginx/fastcgi.conf;
           fastcgi_index index.php;
       if (!-e $request_filename) {
          rewrite ^(.+)$ /wordpress/index.php?q=$1 last;

and my /etc/nginx/fastcgi.conf:

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

my wordpress is physically hosted inside of /wordpress/

otherwise, everything else is handled by either normal handling or the
!-e check, which passes it through wordpress.

piece of cake :)

configure for PHP

'./configure'  '--enable-fastcgi' '--enable-discard-path'
'--enable-force-cgi-redirect' '--enable-fpm'
'--with-fpm-conf=/etc/php-fpm.conf' '--enable-cli'
'--enable-inline-optimization' '--disable-rpath' '--disable-ipv6'
'--enable-mbstring' '--enable-mbregex' '--enable-sqlite-utf8'
'--with-mysql' '--with-mysqli=/usr/bin/mysql_config' '--with-curl'
'--with-zlib' '--with-gd' '--with-jpeg-dir=/usr' '--with-png-dir=/usr'
'--with-freetype-dir' '--enable-gd-native-ttf' '--enable-exif'
'--enable-shmop' '--with-xsl=shared' '--with-mssql=shared'
'--enable-soap=shared' '--enable-sockets' '--enable-pcntl=shared'
'--with-mcrypt' '--with-bz2' '--with-tidy' '--with-pcre-dir'
'--with-imap=shared' '--with-imap-ssl' '--with-kerberos' '--with-pear'

On 4/25/08, Todd HG <lists at> wrote:

> Since you were able to successfully get Nginx to run Wordpress, would
> you mind posting your config file?

More information about the nginx mailing list