This topic describes the following issue and how to resolve the issue: The "No input file specified" error is returned when I access websites deployed on an Elastic Compute Service (ECS) instance.
Problem description
When I access websites deployed on an ECS instance, the "No input file specified" error is returned, as shown in the following figure.
Causes
In most cases, this issue occurs because the web server cannot find the specified Hypertext Preprocessor (PHP) file or script. The web server may be unable to find the PHP file or script because of the following reasons:
The hidden
.user.ini
configuration file is located in the directory of the website that you want to access, and the list of directories specified by theopen_basedir
configuration does not include the website directory. Specify the website directory in the open_basedir configuration. For more information, see the "Manually add the website directory to the hidden .user.ini configuration file" section of this topic.The configuration file of the website that you want to access contains a pseudo-static rule error. As such, the file cannot be read by the web server. Fix the rule error in the configuration file of the website. For more information, see the "Modify the pseudo-static rule settings in the configuration file of the website for Apache" section of this topic.
The operating mode settings in the website configuration file are invalid. As such, the file cannot be read by the web server. Modify the operating mode of the PHP program in the website configuration file. For more information, see the "Specify the operating mode of the PHP program in the website configuration file for IIS and NGINX" section of this topic.
Solutions
Add the website directory to the hidden .user.ini
configuration file
Check whether the hidden .user.ini
configuration file exists in the website directory. If yes, check whether the directories specified by the open_basedir
configuration in the file include the website directory. If not, add the website directory to the open_basedir configuration.
Suppose that the website directory is /www/wwwroot/www.abc.com
. Set open_basedir
to /www/wwwroot/www.abc.com/:/tmp/
in the hidden .user.ini
configuration file to add the website directory to the open_basedir
configuration, as shown in the following figure.
Modify the pseudo-static rule settings in the configuration file of the website for Apache
Check whether the hidden .htaccess
configuration file exists in the website directory. If yes, check whether the RewriteRule
rule is properly specified in the file. If the rule is not properly specified, modify the rule.
Suppose that a question mark (?) is missing from index.php
in the RewriteRule ^(.*)$ /index.php?/$1 [L]
pseudo-static rule. Perform the following operations to modify the rule:
Connect to the ECS instance.
For more information, see Connection methods.
Open the
.htaccess
file, find the line that containsRewriteRule
, and then add a question mark (?) after theindex.php
parameter, as shown in the following figure.Note.htaccess
is an Apache configuration file that allows users to change the configuration for each directory. You can configure pseudo-static settings in the .htaccess file. In most cases, the file is located in the root directory of the website. The actual file path varies based on your environment.RewriteRule ^(.*)$ /index.php?/$1 [L]
Access the website again.
If the website can be accessed, the issue is resolved.
Specify the operating mode of the PHP program in the website configuration file for IIS and NGINX
Specify the operating mode of the PHP program in the configuration file of the website by modifying operating mode settings. This section describes how to set the operating mode of the PHP program to CGI for Internet Information Services (IIS) and NGINX.
IIS
Connect to the Windows instance.
For more information, see Connection methods.
Modify the
php.ini
file.Open the
php.ini
file.NoteIn this example, the path of the
php.ini
file isC:\php\54
. Replace it with the actual path of thephp.ini
file.Comment out code.
Find the line that contains the
doc_root
field in thephp.ini
file. Then, add a semicolon (;) at the beginning of this line to comment out the line, as shown in the following figure.Modify code.
Find the
;cgi.force_redirect = 1
line in thephp.ini
file. Then, delete the semicolon (;) and change1
to0
, as shown in following figure.
Restart IIS.
NoteIn this example, an instance that runs Windows Server 2012 R2 Datacenter 64-bit (Simplified Chinese) is used. The steps that you must perform vary based on your operating system.
In the lower-left corner of the desktop, click the icon and enter
iisreset
in the search box in the upper-right corner.Click iisreset.
After iisreset is run, IIS is restarted.
Access the website again.
If the website can be accessed, the issue is resolved.
NGINX
Connect to the ECS instance.
For more information, see Connection methods.
Open the
/etc/php5/cgi/php.ini
file and make sure that thecgi.fix_pathinfo = 1
is specified in the file.NoteReplace it with the actual path of the php.ini file.
Open the
fastcgi.conf
configuration file and check that the file contains the following code:fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $document_root;
If code is not properly configured in the
fastcgi.conf
configuration file, modify the code, and save the modification. The following figure provides an example of the modified code.Run the following command to restart NGINX:
service nginx restart
Access the website again.
If the website can be accessed, the issue is resolved.
If none of the above solutions resolve the issue, check the error logs of the web server and troubleshoot the issue.