跳到内容
[广告]欧美亚马逊SSN账号、炮灰号开售 ×

“no input file specified”错误原因与解决策略


推荐帖

No Input File Specified这意味着你没有将要执行的php文件的路径传递给php-fpm.这是由SCRIPT_FILENAME参数传递的.

出于安全考虑,它有好处cgi.fix_pathinfo=0.Symfony将与它合作不用担心.

php块是重要的部分.

location ~ .php$ 这意味着如果uri以”.php”结尾,它将被传递给php.现在如果有一个图像并且一些攻击者用它添加”.php”,启用了fix_pathinfo它将被传递给php处理程序并且可以在服务器中执行任意代码.所以我建议你添加cgi.fix_pathinfo=0php.ini并fastcgi_split_path_info ^(.+.php)(/.+)$;从nginx中删除.

我用于symfony2的配置是,

server {
    listen       80;
    server_name projectname.local;

    root /Users/sarim/Sites/php55/projectname/web;
    index app_dev.php index.html index.htm;

    location / {
    try_files $uri $uri/ /app_dev.php?$args;
    }

    location ~ ^/(app|app_dev|config).php(/|$) {
        fastcgi_pass   unix:/usr/local/var/run/php55.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

在这里检查location /块.try_files $ uri $ uri /确保提供静态文件.然后如果它不是静态文件,则传递给/app_dev.php.

现在检查php位置块,只能访问app或app_dev或config.php.没有任意文件执行.现在重要的fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;路线.它应该始终是$ document_root $ fastcgi_script_name.这样php可以找到该文件.

常见的Nginx + PHP错误消息“未指定输入文件。”

"no input file specified"错误原因与解决策略

nginx.conf

http {    include       mime.types;    default_type  application/octet-stream;     server {        listen       80;        server_name  localhost;         location / {            root www;            index  index.html index.htm;        } 		location ~ .php$ {			fastcgi_pass   127.0.0.1:9999;			fastcgi_index  index.php;			fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;			include        fastcgi_params;		}     } }

经过Nginx 1.12.1 + PHP 7.1测试

PHP无法找到要执行的.php文件,因为location / {}中的根文件路径不适用于location ~ .php$ 。

要解决此问题,请将根文件路径移动到服务器块,如下所示:

nginx.conf

http {    include       mime.types;    default_type  application/octet-stream;
评论链接
在其他网站上分享

创建账户或登录以发表评论

您需要成为会员才能发表评论

创建一个帐户

在我们的社区注册一个新账户。很简单!

注册新账户

登入

已有账户?在此登录

立即登录
  • 告诉你朋友

    喜欢 西塞网络科技?告诉朋友!
×
×
  • 创建新的...

重要信息

我们在您的设备上放置了 cookies,以帮助改善本网站。您可以调整您的 cookie 设置,否则我们会假定您可以继续

版权所有 © 2018-2025 西塞网络科技
粤公网安备44200002444913号