WordPress.org

Ready to get started?Download WordPress

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

nginx Compatibility

The plugin makes WordPress more friendly to nginx.

nginx Configuration

nginx 0.7.32 and higher:

server {
    server_name mysite.com;

    root /path/to/blog;

    index index.php;

    error_page 404 = @wordpress;
    log_not_found off;

    location ^~ /files/ {
        rewrite /files/(.+) /wp-includes/ms-files.php?file=$1 last;
    }

    location @wordpress {
        fastcgi_pass ...;
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_NAME /index.php;
    }

    location ~ \.php$ {
        try_files $uri @wordpress;
        fastcgi_index index.php;
        fastcgi_pass ...;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

    location ^~ /blogs.dir/ {
        internal;
        root /path/to/blog/wp-content;
    }
}

Older versions:

server {
    server_name mysite.com;

    root /path/to/blog;

    index index.php;

    log_not_found off;
    error_page 404 = @wordpress;

    location ^~ /files/ {
        rewrite /files/(.+) /wp-includes/ms-files.php?file=$1 last;
    }

    location @wordpress {
        fastcgi_pass ...;
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_NAME /index.php;
    }

    location ~ \.php$ {
        if (!-e $request_filename) {
            rewrite ^(.+)$ /index.php break;
            break;
        }

        fastcgi_index index.php;
        fastcgi_pass ...;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

    location ^~ /blogs.dir/ {
        internal;
        root /path/to/blog/wp-content;
    }
}

Of course, do not forget to replace ... in fastcgi_pass with the address/socket php-cgi is listening on and replace /path/to/blog with the actual path.

Also please note that the path in SCRIPT_NAME should be relative to the DOCUMENT_ROOT (root directive). Thus, if your WordPress blog resides in http://example.com/blog/, root is set to /path.to/example.com,

SCRIPT_NAME

in location @wordpress will be /blog/index.php.

Multi-Site Configuration: the above configs work perfectly with WordPress MultiSite. To make downloads faster, consider adding this line to wp-config.php:

define('WPMU_ACCEL_REDIRECT', true);

Need help with configuring nginx? Contact me: vkolesnikov at odesk dot com, I will try to help you.

Requires: 2.5 or higher
Compatible up to: 3.2.1
Last Updated: 2011-7-4
Downloads: 23,966

Ratings

4 stars
4.2 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1
100,2,2 100,1,1
100,1,1 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1
100,2,2 100,1,1
100,2,2 100,2,2
67,3,2 100,1,1 100,1,1
100,7,7 100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1
100,1,1
100,2,2
100,1,1
100,1,1
100,2,2
50,2,1
100,1,1 100,1,1 75,4,3
100,3,3
50,2,1
100,1,1
0,1,0
100,1,1