【发布时间】:2015-04-28 20:19:42
【问题描述】:
我最近刚从 Apache 迁移到 Nginx,我遇到了 Wordpress 和 Nginx 的障碍。目前我正在运行一个更简单的 Nginx conf,这样您就可以更轻松地查看发生了什么,而无需再查看 50 行以上的代码。
server {
listen 80;
server_name servername.com
root /home/sname/www;
# IF I DON'T DO THIS ALL PAGES APART FROM THE HOMEPAGE DON'T APPEAR!
# Further to this, I use a custom permalink structure %post_name%.
# When turned off the pages work but I can't use custom permalink structure
error_page 404 /index.php;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# PHP Handler
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我拥有 HTTP 块中的所有常规:
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
index index.php index.html index.htm;
include /etc/nginx/conf.d/*.conf;
为什么我不能忍受这个?好吧,这是一个站点范围的示例。 (在站点名称中替换!由于错误的 URL 和链接限制)
http://www.pro-tradesouthwales.co.uk/services/damp-proofing/
网站名称!/services/damp-proofing/index.php/index.php
任何和所有的帮助表示赞赏。我已经尝试了很多不同的设置,并试图让它工作好几天。请不要光顾我说读指南之类的话,我吃了该死的 nginx 字典仍然无济于事:)
谢谢大家!
【问题讨论】:
-
如果删除 try_files $uri =404; 会发生什么PHP处理程序中的行?另外,您在任何地方都有大致的位置/街区吗?
标签: wordpress nginx url-rewriting