我的域配置如下:
server {
listen 80;
root /var/www/domains/somedomain/root;
location = /service/alias/ {
alias /var/www/service/alias/;
index index.php;
}
location ~ '.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
当有人请求时,我想在/var/www/service/alias/
中执行index.php
文件http://example.com/service/alias.我尝试了许多变体(将FastCGI参数放在位置并提供index.php
脚本的完整路径),但我一直从php-FastCGI中得到"未指定输入文件"的错误。
有人知道我做错了什么吗?或者至少Ii如何记录php-fastcgi的全部错误?
index
在服务器范围内更好,因为所有其他位置都将包含该值,特别是如果它们是相等的多个索引,并且我希望我的php块尽可能小,因为大多数其他选项已经包含在fastcgi_params
中,我还认为fastcgi_pass
应该传递给http://
,而不是直接传递给IP,所以试试这个版本,告诉我它是否适合你。
server {
listen 80;
# added a server name, unless it's a catch all virtual host
# then you better use `default_server` with `listen`
server_name example.com;
root /var/www/domains/somedomain/root;
# index moved here
index index.php;
location = /service/alias/ {
# why `=` ? I would remove it unless there's a purpose
# index removed from here
alias /var/www/service/alias/;
}
location ~* '.php$ {
#removed all other options
include fastcgi_params;
# added `http` before `127.0.0.1`
fastcgi_pass http://127.0.0.1:9000;
}
}