這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
linux:web:nginx_wordpress [2014/06/12 02:30] ali88 |
linux:web:nginx_wordpress [2014/06/12 02:40] (目前版本) ali88 |
||
---|---|---|---|
行 6: | 行 6: | ||
======Nginx Rewrite rule設定====== | ======Nginx Rewrite rule設定====== | ||
- 接下來需要搭配Nginx rewrite方式才能達到wordpress固定網址。 | - 接下來需要搭配Nginx rewrite方式才能達到wordpress固定網址。 | ||
- | - 若不採用Nginx rewrite作法就會產生以下錯誤。 | + | - 若不採用Nginx rewrite作法就會產生以下錯誤。{{:linux:web:no_nginx_error_wordpress.png|}} |
- | {{:linux:web:no_nginx_error_wordpress.png|}} | + | - Nginx Rewrite 設定,當client端 $request_filename 不存在,就將全部檔案導到 wordpress 根目錄下的 index.php<code> |
+ | server { | ||
+ | listen 80; | ||
+ | server_name ~^(www\.)?test202.com; | ||
+ | root /var/www/html/test2; | ||
+ | #charset koi8-r; | ||
+ | access_log /var/log/nginx/test-access.log main; | ||
+ | error_log /var/log/nginx/test-error.log; | ||
+ | |||
+ | |||
+ | |||
+ | if (!-e $request_filename) | ||
+ | { | ||
+ | rewrite ^(.+)$ /index.php?q=$1 last; | ||
+ | } | ||
+ | |||
+ | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | ||
+ | location ~ \.php$ { | ||
+ | #error_page 404 /404.html; | ||
+ | if (!-f $request_filename) { | ||
+ | return 404; | ||
+ | } | ||
+ | fastcgi_pass 127.0.0.1:9000; | ||
+ | fastcgi_index index.php; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | #error_page 500 502 503 504 /50x.html; | ||
+ | location = /50x.html { | ||
+ | root /usr/share/nginx/html; | ||
+ | } | ||
+ | } | ||
+ | </code> | ||