php
我在使用 nginx 网络服务器上的测试文件时遇到了问题。
出于某种原因,每次我试图到达http://localhost/test.php我遇到了著名的错误No input file specified
。
打开错误日志后,我看到以下消息:
[error] FastCGI sent in stderr: "Unable to open primary script: **/etc/nginx/html/**test.php (No such file or directory)" while reading response header from upstream, client: PUBLIC_IP, server: localhost, request: "GET /test.php HTTP/1.1"
由于某种原因,nginx 服务认为我的 webroot 目录是/etc/nginx/html/
,这显然不是我想要的位置。
这是我的 default.conf:
server {
listen 80;
server_name localhost;
#charset koi8-r;
access_log /var/log/nginx/host.access.log main;
error_log /var/log/nginx/error.log;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /{
try_files $uri $uri/ /index.php$args;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php${
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm.sock
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我找不到这个配置在哪里。我做错了什么?