Solve the "No input file specified" problem in Nginx

Source: Internet
Author: User

If you are using Nginx and php-cgi, you may encounter an error like "No input file specified" after installing them according to some standard procedures. This error usually occurs when the php-cgi process cannot find the ". php" file or execute the parameters passed by "SCRIPT_FILENAME. This article discusses several causes and solutions for this error.

(1) incorrect path

Generally, the file path (SCRIPT_FILENAME) is set incorrectly, so that the fastCGI process cannot be parsed. In most cases, Nginx configuration errors occur. Many configurations are as follows:


Server {
Listen [:]: 80;
Server_name example.com www.111cn.net;
Access_log/var/www/logs/example.com. access. log;
 
Location /{
Root/var/www/example.com;
Index. php index.html index.htm;
    }
 
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;
    }
}

This configuration contains a write error. An obvious eye-catching error is that the root specifies "location/". When the root directory root is defined in this "location", it only takes effect within the current speed. The "location/images" block here will not apply to other requests because it is not defined in "$ document _ root. For it, setting the root directory root is redundant. In general, the root directory root should be removed from the "location/" to the "server" block. In this way, the location block can inherit the value defined in the "server" block. Of course, if you want to define a different "$ document_root" for a "location" location, you can specify a location pointing to it in the root directory "location.
Another reason is that the value of the fastCGI parameter "SCRIPT_FILENAME" is written to death. If the root path we changed points to and the value here is not changed, php-cgi will return the "No input file specified" error, because it does not find the corresponding file in the dead path. Therefore, we should set "SCRIPT_FILENAME" like this ":
 
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;


We should remember to specify the root directory in the server block.
(2) permissions are incorrectly set.
The root directory permission is incorrectly set.
(3) use Open Basedir to strictly limit the path
If php. ini strictly limits the path of the php file, the above error message may appear even if the nginx configuration is correct. You need to modify the value of "open_basedir =" in php. ini to be consistent with the specified root directory,
(4) the file does not exist.
Make sure the file exists.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.