[英]500 error with Nginx and WordPress pretty permalinks
在運行Nginx和WP並設置相當永久鏈接時遇到500問題。 我一直在嘗試谷歌的一些不同的方法,但似乎沒有任何幫助。
配置 -
server {
listen 80;
root /var/www/mydomain.com/public_html;
index index.php index.html index.htm;
server_name .mydomain.com;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
所有文件都可以很好地加載,如果使用默認的永久鏈接設置,則頁面可以正常工作。 奇怪的是,如果我檢查網絡日志我首先看到200 OK正在收到,然后立即跟着500.任何想法?
編輯:設置關閉,因為我轉而使用Apache。 將標記正確答案,因為它似乎幫助了其他人。
嘗試:
try_files $uri $uri/ /index.php?q=$uri&$args;
和:
fastcgi_index /index.php;
(注意/)
Rufinus的回答也是正確的。
這是對的。 你忘了定義索引。 所以nginx不知道要鎖定和處理哪個文件。 希望這能幫到你。
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
您的Config沒有fastcgi_parm 。
將此行添加到您的配置中。 它是Nginx Config的主要部分。
使用您的網站路徑位置更改/ home / public_html
fastcgi_param SCRIPT_FILENAME /home/public_html$fastcgi_script_name;
這是我的整個wordpress配置文件。 我希望有效。 它的工作Nginx配置文件與漂亮的網址。
server {
listen 80;
server_name example.com;
root /home/public_html;
index index.php index.htm index.html;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /favicon.ico { access_log off; log_not_found off; }
location ~* \.(jpg|jpeg|gif|png|js|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/public_html$fastcgi_script_name;
include fastcgi_params;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.