{"id":5328,"date":"2009-04-15T10:44:42","date_gmt":"2009-04-15T10:44:42","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/nginx-compatibility\/"},"modified":"2011-07-04T17:25:31","modified_gmt":"2011-07-04T17:25:31","slug":"nginx-compatibility","status":"closed","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/nginx-compatibility\/","author":1064655,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"0.2.5","stable_tag":"0.2.5","tested":"3.2.1","requires":"2.5","requires_php":"","requires_plugins":"","header_name":"nginx Compatibility (PHP5)","header_author":"Vladimir Kolesnikov","header_description":"","assets_banners_color":"","last_updated":"2011-07-04 17:25:31","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/blog.sjinks.pro\/feedback\/","header_plugin_uri":"http:\/\/blog.sjinks.pro\/wordpress-plugins\/nginx-compatibility\/","header_author_uri":"http:\/\/blog.sjinks.pro\/","rating":3.7,"author_block_rating":0,"active_installs":90,"downloads":36812,"num_ratings":3,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":"1","2":0,"3":0,"4":0,"5":"2"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.1","0.1.1","0.2","0.2.1","0.2.2","0.2.3","0.2.4","0.2.5"],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[45947,2437,11490],"plugin_category":[],"plugin_contributors":[80088],"plugin_business_model":[],"class_list":["post-5328","plugin","type-plugin","status-closed","hentry","plugin_tags-fastcgi","plugin_tags-nginx","plugin_tags-pretty-permalinks","plugin_contributors-vladimir_kolesnikov","plugin_committers-vladimir_kolesnikov"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/nginx-compatibility.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>The plugin solves two problems:<\/p>\n\n<ol>\n<li>When WordPress detects that FastCGI PHP SAPI is in use, it\n<a href=\"http:\/\/blog.sjinks.pro\/wordpress\/510-wordpress-fastcgi-and-301-redirect\/\">disregards the redirect status code<\/a>\npassed to <code>wp_redirect<\/code>. Thus, all 301 redrects become 302 redirects\nwhich may not be good for SEO. The plugin overrides <code>wp_redirect<\/code> when it detects\nthat nginx is used.<\/li>\n<li>When WordPress detects that <code>mod_rewrite<\/code> is not loaded (which is the case for nginx as\nit does not load any Apache modules) it falls back to <a href=\"http:\/\/codex.wordpress.org\/Using_Permalinks#PATHINFO:_.22Almost_Pretty.22\">PATHINFO permalinks<\/a>\nin Permalink Settings page. nginx itself has built-in support for URL rewriting and does not need\nPATHINFO permalinks. Thus, when the plugin detects that nginx is used, it makes WordPress think\nthat <code>mod_rewrite<\/code> is loaded and it is OK to use pretty permalinks.<\/li>\n<\/ol>\n\n<p>The plugin does not require any configuration. It just does its work.\nYou won't notice it \u2014 install and forget.<\/p>\n\n<p><strong>WARNING:<\/strong> nginx must be configured properly to support permalinks.<\/p>\n\n<h3>nginx Configuration<\/h3>\n\n<p><strong>nginx 0.7.32 and higher:<\/strong><\/p>\n\n<pre><code>server {\n    server_name mysite.com;\n\n    root \/path\/to\/blog;\n\n    index index.php;\n\n    error_page 404 = @wordpress;\n    log_not_found off;\n\n    location ^~ \/files\/ {\n        rewrite \/files\/(.+) \/wp-includes\/ms-files.php?file=$1 last;\n    }\n\n    location @wordpress {\n        fastcgi_pass ...;\n        fastcgi_param SCRIPT_FILENAME $document_root\/index.php;\n        include \/etc\/nginx\/fastcgi_params;\n        fastcgi_param SCRIPT_NAME \/index.php;\n    }\n\n    location ~ \\.php$ {\n        try_files $uri @wordpress;\n        fastcgi_index index.php;\n        fastcgi_pass ...;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        include \/etc\/nginx\/fastcgi_params;\n    }\n\n    location ^~ \/blogs.dir\/ {\n        internal;\n        root \/path\/to\/blog\/wp-content;\n    }\n}\n<\/code><\/pre>\n\n<p><strong>Older versions:<\/strong><\/p>\n\n<pre><code>server {\n    server_name mysite.com;\n\n    root \/path\/to\/blog;\n\n    index index.php;\n\n    log_not_found off;\n    error_page 404 = @wordpress;\n\n    location ^~ \/files\/ {\n        rewrite \/files\/(.+) \/wp-includes\/ms-files.php?file=$1 last;\n    }\n\n    location @wordpress {\n        fastcgi_pass ...;\n        fastcgi_param SCRIPT_FILENAME $document_root\/index.php;\n        include \/etc\/nginx\/fastcgi_params;\n        fastcgi_param SCRIPT_NAME \/index.php;\n    }\n\n    location ~ \\.php$ {\n        if (!-e $request_filename) {\n            rewrite ^(.+)$ \/index.php break;\n            break;\n        }\n\n        fastcgi_index index.php;\n        fastcgi_pass ...;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        include \/etc\/nginx\/fastcgi_params;\n    }\n\n    location ^~ \/blogs.dir\/ {\n        internal;\n        root \/path\/to\/blog\/wp-content;\n    }\n}\n<\/code><\/pre>\n\n<p>Of course, do not forget to replace <code>...<\/code> in <code>fastcgi_pass<\/code> with the address\/socket\nphp-cgi is listening on and replace \/path\/to\/blog with the actual path.<\/p>\n\n<p>Also please note that the path in <code>SCRIPT_NAME<\/code> should be relative to the <code>DOCUMENT_ROOT<\/code> (<code>root<\/code> directive).\nThus, if your WordPress blog resides in <code>http:\/\/example.com\/blog\/<\/code>, <code>root<\/code> is set to <code>\/path.to\/example.com<\/code>,\n    SCRIPT_NAME in <code>location @wordpress<\/code> will be <code>\/blog\/index.php<\/code>.<\/p>\n\n<p><strong><a href=\"http:\/\/blog.sjinks.pro\/wordpress\/874-wpms-nginx-accel-redirect\/\">Multi-Site Configuration<\/a>:<\/strong> the above configs work perfectly with WordPress MultiSite. To make downloads faster, consider adding this line to <code>wp-config.php<\/code>:<\/p>\n\n<pre><code>define('WPMU_ACCEL_REDIRECT', true);\n<\/code><\/pre>\n\n<p><strong>Need help with configuring nginx?<\/strong> Contact me: vkolesnikov at odesk dot com, I will try to help you.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload <code>nginx-compatibility<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory.<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress. The plugins comes in two flavors: PHP4 (experimental) and PHP5. Please activate\nthe flavor that matches your PHP version.<\/li>\n<li>That's all :-)<\/li>\n<\/ol>\n\n<!--section=faq-->\n<p>None yet. Be the first to ask.<\/p>\n\n<!--section=changelog-->\n<h4>0.2.5<\/h4>\n\n<ul>\n<li>Added code to prevent path disclosure<\/li>\n<\/ul>\n\n<h4>0.2.4<\/h4>\n\n<ul>\n<li>Updated nginx Configuration section to reflect the changes necessary for WordPress 3.0+<\/li>\n<\/ul>\n\n<h4>0.2.3<\/h4>\n\n<ul>\n<li>Detects nginx when <code>server_tokens<\/code> is off (props Serge Pokhodyaev)<\/li>\n<\/ul>\n\n<h4>0.2.2<\/h4>\n\n<ul>\n<li>Better HTTPS handling<\/li>\n<li>Updated \"nginx Configuration\" section<\/li>\n<li>Fixed a bug with multiple calls to <code>wp_redirect()<\/code> (props KeRNel_x86)<\/li>\n<\/ul>\n\n<h4>0.2.1<\/h4>\n\n<ul>\n<li>Code refactoring using <a href=\"http:\/\/blog.sjinks.pro\/php\/651-php-code-beauty-impacts-performance-part-2\/\" title=\"PHP Code Beauty Impacts Performance\">PHP code optimization methods<\/a><\/li>\n<li>Supported WP versions: 2.5-2.9<\/li>\n<\/ul>\n\n<h4>0.2<\/h4>\n\n<ul>\n<li>Added experimental PHP4-compatble version of the plugin<\/li>\n<\/ul>\n\n<h4>0.1.1<\/h4>\n\n<ul>\n<li>Added status code check to <code>wp_redirect<\/code><\/li>\n<\/ul>\n\n<h4>0.1<\/h4>\n\n<ul>\n<li>First public release<\/li>\n<\/ul>","raw_excerpt":"The plugin makes WordPress more friendly to nginx.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/5328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=5328"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/vladimir_kolesnikov"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=5328"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=5328"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=5328"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=5328"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=5328"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=5328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}