网站首页 > 技术文章 正文
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错误消息“未指定输入文件。”
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;     server {        listen       80;        server_name  localhost; 		# Move the root file path to server block.		root www;		        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;		}     } }猜你喜欢
- 2025-01-21 30s 就可以掌握的 Nginx 片段
- 2025-01-21 Nginx域名配置
- 2025-01-21 Nginx配置终极手册:一站式详尽教程
- 2025-01-21 HHvm建站环境搭建方法:Nginx、lnmp/lamp等安装部署
- 2025-01-21 nginx修改conf后不生效的解决方法与root|alias总结
- 2025-01-21 前端项目中 浏览器缓存的更新不及时问题及解决方法
- 2025-01-21 Nginx反向代理:通过外网访问内网数据库(mysql)
- 2025-01-21 如何使用 Daphne + Nginx + supervisor部署 Django
- 2025-01-21 如何在Docker中打包部署Vue项目
- 2025-01-21 有遇到部署服务器后刷新404问题吗?
- 最近发表
- 
- 聊一下 gRPC 的 C++ 异步编程_grpc 异步流模式
- [原创首发]安全日志管理中心实战(3)——开源NIDS之suricata部署
- 超详细手把手搭建在ubuntu系统的FFmpeg环境
- Nginx运维之路(Docker多段构建新版本并增加第三方模
- 92.1K小星星,一款开源免费的远程桌面,让你告别付费远程控制!
- Go 人脸识别教程_piwigo人脸识别
- 安卓手机安装Termux——搭建移动服务器
- ubuntu 安装开发环境(c/c++ 15)_ubuntu安装c++编译器
- Rust开发环境搭建指南:从安装到镜像配置的零坑实践
- Windows系统安装VirtualBox构造本地Linux开发环境
 
- 标签列表
- 
- cmd/c (90)
- c++中::是什么意思 (84)
- 标签用于 (71)
- 主键只能有一个吗 (77)
- c#console.writeline不显示 (95)
- pythoncase语句 (88)
- es6includes (74)
- sqlset (76)
- apt-getinstall-y (100)
- node_modules怎么生成 (87)
- chromepost (71)
- flexdirection (73)
- c++int转char (80)
- mysqlany_value (79)
- static函数和普通函数 (84)
- el-date-picker开始日期早于结束日期 (76)
- js判断是否是json字符串 (75)
- c语言min函数头文件 (77)
- asynccallback (87)
- localstorage.removeitem (77)
- vector线程安全吗 (73)
- java (73)
- js数组插入 (83)
- mac安装java (72)
- 无效的列索引 (74)
 
