Nginx + php fastcgi显示“未指定输入文件".而不是404

编程入门 行业动态 更新时间:2024-10-25 08:15:35
本文介绍了Nginx + php fastcgi显示“未指定输入文件".而不是404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的问题很简单.

当我请求一个不存在的.php文件时,看到的是未指定输入文件.",而不是您期望的404页面.

When I request a .php file that doesn't exist, I see "No input file specified.", instead of the 404 page that you would expect.

我知道我正在将所有扩展名为.php的请求传递给php-fpm,并且我猜想php-fpm返回未指定输入文件".文件不存在时(?). 我该如何解决?

I get that i am passing all requests with a .php extension to php-fpm, and i guess that php-fpm returns "No input file specified." when the file does not exist(?). How do i fix this?

/etc/nginx/nginx.conf:

/etc/nginx/nginx.conf:

http { server { listen 443 ssl; server_name smarthome.dk; ssl_certificate /home/www/SmartHome/cert/ssl.crt; ssl_certificate_key /home/www/SmartHome/cert/ssl.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; keepalive_timeout 70; root /home/www/SmartHome/public_html; index index.php index.html; location / { try_files $uri $uri/ /404.php?$args; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; } }

我在/etc/php5/fpm/php.ini中有cgi.fix_pathinfo = 0;.

I have cgi.fix_pathinfo = 0; in /etc/php5/fpm/php.ini.

推荐答案

我知道了

您需要将try_files $uri $uri/ /404.php?$args;添加到location ~\.php$

未指定输入文件,因为该文件不存在,因此不会传递. try_files $uri $uri/ /404.php?$args;检查文件是否确实存在,否则将重定向到404.php

No input file is specified because the file does not exist, and therefore is not passed. try_files $uri $uri/ /404.php?$args; checks that the file does actually exist, otherwise it redirects to 404.php

更多推荐

Nginx + php fastcgi显示“未指定输入文件".而不是404

本文发布于:2023-11-01 12:19:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   文件   php   Nginx   fastcgi

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!