嗨,我需要帮助设置配置为nginx.我是NGINX的新手,面临一些问题.
在我sites-available的default文件中
它包含以下代码
server {
server_name www.test.com test.com;
access_log /sites/test/logs/access.log;
error_log /sites/test/logs/error.log;
root /sites/test;
location ~ / {
index index.php
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Run Code Online (Sandbox Code Playgroud)
上面的代码在我写URL时非常有效
www.test.com/service/public/
Run Code Online (Sandbox Code Playgroud)
我写的时候
www.test.com/service/public/testservice (testservice是公共文件夹)它说 No input file specified.
如何解决它.提前致谢.
我在下面试过,但没有运气
http://nginxlibrary.com/resolving-no-input-file-specified-error/
http://blog.martinfjordvald.com/2011/01/no-input-file-specified-with-php-and-nginx/
Run Code Online (Sandbox Code Playgroud)
小智 24
您必须添加"include fastcgi.conf"
location ~ \.$php{
#......
include fastcgi.conf;
}
Run Code Online (Sandbox Code Playgroud)
eve*_*een 16
解决"未指定输入文件"错误
如果您正在使用带有php-cgi的nginx并且已按照标准过程进行设置,那么您可能经常会收到"未指定输入文件"错误.当php-cgi守护程序无法使用提供给它的SCRIPT_FILENAME参数找到要执行的.php文件时,基本上会发生此错误.我将讨论错误的常见原因及其解决方案.错误的路径被发送到php-cgi守护进程
通常会将错误的路径(SCRIPT_FILENAME)发送到fastCGI守护程序.在许多情况下,这是由于配置错误造成的.我见过的一些设置配置如下:
server {
listen [::]:80;
server_name example.com www.example.com;
access_log /var/www/logs/example.com.access.log;
location / {
root /var/www/example.com;
index index.html index.htm index.pl;
}
location /images {
autoindex on;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/example.com$fastcgi_script_name;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,这种配置有很多问题.一个明显且明显的问题是位置/块中的根指令.当在位置块内定义根时,它仅为该块可用/定义.这里,位置/图像块不匹配任何请求,因为它没有定义任何$ document _root,我们将不得不为它再次冗余地定义root.显然,root指令应该移出位置/块并在服务器块中定义.这样,位置块将继承父级服务器块中定义的值.当然,如果要为位置定义不同的$ document_root,可以将根指令放在位置块中.
另一个问题是fastCGI参数SCRIPT_FILENAME的值是硬编码的.如果我们更改root指令的值并将我们的文件移动到目录链中的其他位置,php-cgi将返回"未指定输入文件"错误,因为无法在硬编码位置找到该文件$ document_root更改时更改.所以,我们应该将SCRIPT_FILENAME设置如下:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Run Code Online (Sandbox Code Playgroud)
我们应该记住,root指令应该在服务器块中,否则,只有$ fastcgi_script_name将作为SCRIPT_FILENAME传递,我们将得到"未指定输入文件"错误.
这可能是因为使用尾部斜杠,NGinx 尝试查找默认索引文件,该文件可能是没有配置的index.html。如果没有尾部斜杠,它会尝试匹配他找不到的文件testservice 。要么是这个,要么是您的文件夹中没有任何默认索引文件testservice。
尝试将此行添加到您的server配置中:
index index.php index.html index.htm; // Or in the correct priority order for you
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!
编辑
我的回答不是很清楚,看这个例子就明白我的意思了
listen 80;
server_name glo4000.mydomain.com www.glo4000.mydomain.com;
access_log /var/log/nginx/glo-4000.access.log;
error_log /var/log/nginx/glo-4000.error_log;
location / {
root /home/ul/glo-4000/;
index index.php index.html index.htm;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/ul/glo-4000/$fastcgi_script_name;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
91947 次 |
| 最近记录: |