All Products
Search
Document Center

:What do I do if the "No input file specified" error is returned when I access websites deployed on an ECS instance?

Last Updated:May 25, 2023

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.Problem description

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:

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.image

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:

  1. Connect to the ECS instance.

    For more information, see Connection methods.

  2. Open the .htaccess file, find the line that contains RewriteRule, and then add a question mark (?) after the index.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]
    Apache modification
  3. 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

  1. Connect to the Windows instance.

    For more information, see Connection methods.

  2. Modify the php.ini file.

    1. Open the php.ini file.

      Note

      In this example, the path of the php.ini file is C:\php\54. Replace it with the actual path of the php.ini file.

    2. Comment out code.

      Find the line that contains the doc_root field in the php.ini file. Then, add a semicolon (;) at the beginning of this line to comment out the line, as shown in the following figure.Comment out the line where doc_root resides

    3. Modify code.

      Find the ;cgi.force_redirect = 1 line in the php.ini file. Then, delete the semicolon (;) and change 1 to 0, as shown in following figure.Modify the cgi code

  3. Restart IIS.

    Note

    In 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.

    1. In the lower-left corner of the desktop, click the Start icon icon and enter iisreset in the search box in the upper-right corner.

    2. Click iisreset.

      After iisreset is run, IIS is restarted.

  4. Access the website again.

    If the website can be accessed, the issue is resolved.

NGINX

  1. Connect to the ECS instance.

    For more information, see Connection methods.

  2. Open the /etc/php5/cgi/php.ini file and make sure that the cgi.fix_pathinfo = 1 is specified in the file.

    Note

    Replace it with the actual path of the php.ini file.

    Nginx cgi
  3. 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.Nginx fastcgi

  4. Run the following command to restart NGINX:

    service nginx restart
  5. 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.