Plugin / nginx Compatibility
Vladimir KolesnikovDescription
Description
The plugin solves two problems:
- When WordPress detects that FastCGI PHP SAPI is in use, it
disregards the redirect status code
passed towp_redirect
. Thus, all 301 redrects become 302 redirects
which may not be good for SEO. The plugin overrideswp_redirect
when it detects
that nginx is used. - When WordPress detects that
mod_rewrite
is not loaded (which is the case for nginx as
it does not load any Apache modules) it falls back to PATHINFO permalinks
in Permalink Settings page. nginx itself has built-in support for URL rewriting and does not need
PATHINFO permalinks. Thus, when the plugin detects that nginx is used, it makes WordPress think
thatmod_rewrite
is loaded and it is OK to use pretty permalinks.
The plugin does not require any configuration. It just does its work.
You won’t notice it — install and forget.
WARNING: nginx must be configured properly to support permalinks.
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.
Ratings
Rating breakdown
Details Information
Version
First Released
Total Downloads
Wordpress Version
Tested up to:
Require PHP Version:
Tags
Contributors
Languages
The plugin hasn't been transalated in any language other than English.
DIRECTORY DISCLAIMER
The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.
The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.
Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.
While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.
wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.