Nginx + PHP No input file specified

摘要: A common Nginx + PHP error message “No input file specified.”

A common Nginx + PHP error message “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;

Tested with Nginx 1.12.1 + PHP 7.1

Solution

PHP unable to find the .php file to execute, because the root file path in location / {} doesn’t apply to the location ~ \.php$.

To solve it, move the root file path to server block like this :

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;

References

  1. Nginx + PHP on Windows
  2. PHP-FastCGI on Windows

上一篇: php-cgi.exe The application was unable to start correctly
下一篇: PrimeFaces Open Window By Dropdown Selection
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号