前言介紹
- 這款 WordPress 外掛「nginx Compatibility」是 2009-04-14 上架。 目前已經下架不再更新,不建議安裝使用。
- 目前有 100 個安裝啟用數。
- 上一次更新是 2011-07-04,距離現在已有 5052 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 2.5 以上版本才可以安裝。
- 有 3 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
nginx | fastcgi | pretty permalinks |
內容簡介
rdPress is installed in a subdirectory, you need to adjust the path accordingly.
Finally, don't forget to save your changes and restart nginx to apply them.
這個外掛解決了兩個問題:
當 WordPress 檢測到使用 FastCGI PHP SAPI 時,它會忽略傳遞給 wp_redirect 的重定向狀態碼。因此,所有的 301 重定向都會變成 302 重定向,這對 SEO 可能不利。該外掛會在檢測到使用 nginx 時,覆蓋 wp_redirect。
當 WordPress 檢測到 mod_rewrite 無法使用時,它會回傳 Permalink 設置頁面中的 PATHINFO permalink。nginx 本身具有 URL 重寫的內置支持,因此不需要使用 PATHINFO permalink。因此,該外掛檢測到使用 nginx 時,使 WordPress 認為 mod_rewrite 已加載,可以使用漂亮的永久鏈接。
該插件不需要進行任何配置,它只要工作就好。安裝並忘記它的存在就好。
警告:nginx 必須正確配置以支持永久鏈接。
nginx 配置
nginx 0.7.32 及更高版本:
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;
}
}
舊版:
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;
}
}
當然,不要忘記在 fastcgi_pass 中用 php-cgi 監聽的地址/套接字替換 ...,並將 /path/to/blog 替換為實際路徑。
請注意,SCRIPT_NAME 中的路徑應該相對於 DOCUMENT_ROOT (root 指令)。因此,如果您的 WordPress 安裝在子目錄中,需要相應地調整路徑。
最後,請不要忘記保存更改並重新啟動 nginx,以應用它們。
原文外掛簡介
The plugin solves two problems:
When WordPress detects that FastCGI PHP SAPI is in use, it
disregards the redirect status code
passed to wp_redirect. Thus, all 301 redrects become 302 redirects
which may not be good for SEO. The plugin overrides wp_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
that mod_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.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「nginx Compatibility」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.1 | 0.2 | 0.1.1 | 0.2.1 | 0.2.2 | 0.2.3 | 0.2.4 | 0.2.5 | trunk |
延伸相關外掛(你可能也想知道)
Nginx Helper 》, 使用 nginx 時,從永久連結中刪除 index.php。, 在使用nginx-srcache-module創建的完整頁面快取時,添加可清除 redis-cache 的支援。, 從模組中添加對 ngin...。
Nginx Cache 》當內容更改時自動清除 Nginx 緩存 (FastCGI、Proxy、uWSGI),或在 WordPress 內手動清除。, 要求:, , Filesystem API 需要在不要求憑證的情況下運作。, Ngin...。
Cleavr Clear Cache 》管理您的 Cleavr 站點的 NGINX FastCGI 快取,只需添加清除快取觸發器鉤子,然後您就可以點擊按鈕來清除您的站點快取,並選擇性地在每次內容更改時清除快取。...。