我有一个简单的 nginx 配置,用于将所有请求传递给/site/index.php
。升级到 ubuntu 12.04 后,此配置不再起作用。
server {
listen 80;
server_name site.com;
root /site/;
access_log /var/log/nginx/site.log;
location / {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /site/index.php;
include fastcgi_params;
}
}
该规则fastcgi_param SCRIPT_FILENAME /site/index.php;
过去将与“location /”匹配的所有内容发送到index.php,但现在我收到 404 错误。
这有效
- 站点/index.php
这不
- 地点
- 網站/資料夾
有任何想法吗 ?
答案1
您的配置中没有指定索引,请尝试下一个配置:
server {
listen 80;
server_name site.com;
root /site/;
access_log /var/log/nginx/site.log;
location / {
index index.php index.html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /site/index.php;
include fastcgi_params;
}
}