Lnmp prompts Nginx PHP "No input file specified" error

Source: Internet
Author: User
Tags fpm ini phpinfo what php file permissions

Yesterday because the server is due to migrate the site to another server, the use of the LNMP architecture, the site after the completion of the relocation of various parts of the problem of the egg pain: A lot of Web page open prompt "No input file specified", or even direct 404, and when good and bad.
Went to the Internet to search the information, probably meaning as follows:

Any requests for. php files are simply given to php-cgi to process, but there is no verification that the PHP file exists. PHP file does not exist, no way to return the normal 404 error, it returned a 404, and with a "No input file specified"
In addition, it may be related to the path or permissions, or the Script_filename variable is not set correctly (this is the most common reason for nginx).

Because Nginx's pathinfo settings are directly replicated before the server's settings, so this is certainly not wrong, then check the PHP configuration file.
First, change the cgi.fix_pathinfo=0 to Cgi.fix_pathinfo=1
B. Cgi.force_redirect=1 to Cgi.force_redirect=0

Then restart the LNMP, found that it is not good, just try the following:
# Cd/home/wwwroot
# chown-r www:www./*
# chmod-r 755./*
# LNMP Restart
And then.. Just fine .... Do half a day incredibly is a simple permission problem, Dizzy ~ ~ ~
Note that after a friend encounters the same problem do not visit to try is not right. By the way, I used the online LNMP one-click installation package 1.2 version, so there are lnmp this command, their own compiler installation LNMP or lamp's own reference nginx and PHP commands)

Another situation

After configuring Nginx + PHP + mysql, add a site:

server {
Listen 80;
server_name www.111cn.net;
root/www/wei.abc.com/;
Index index.html index.htm index.php;

# if (!-f $request _filename) {
# rewrite ^/(. *) $/f.php last;
#       }

Location/{
}

Location ~ \.php$ {
root/www/wei.abc.com;
Fastcgi_pass Unix:/run/php-fpm/php-fpm.sock;
Fastcgi_index index.php;
Include fastcgi.conf;
}
}

Anyway access is no input file specified, open/etc/php/php-fpm.conf, find Access_log Open, Access_format Open, find file path is also correct, with Nginx configuration issues

It is found that the path to PHP in/etc/php.ini is limited:

Open_basedir CMB Web site path Plus, or directly commented out also line (for security reasons, or add a directory is better).

Problem situation Three

Just loaded the nginx, and immediately added a PHPINFO

1.<?php
2.phpinfo ();
3.?>
And then run it under the browser and the result is

No input file specified.

The following is a network collection

There is no input file specified when accessing PHP files in fastcgi mode. Error
View Access.log found is 404

Reason Analysis:
Any requests for. php files are simply given to php-cgi to process, but there is no verification that the PHP file exists. PHP file does not exist, no way to return the normal 404 error, it returned a 404, and with a "No input file specified"

In addition, it may be related to the path or permissions, or the Script_filename variable is not set correctly (this is the most common reason for nginx)

1 if there are 404 errors in HTML, then there is a problem with the document root setting
2 Check script file permissions, maybe php or Web server can not read it
3) Script_filename Set error

can use
Fastcgi_param script_filename $document _root$fastcgi_script_name;
It must be ensured that $document _root in the configuration file, used once in front of Astcgi_param Script_filename, and explained why.

Or
Modify Cgi.fix_pathinfo=1 in/etc/php5/cgi/php.ini
This also allows php-cgi to use the script_filename variable normally

Some say it's OK to change it
Fastcgi_param script_name/home/gavin/nginx/$fastcgi _script_name;

Let's see what PHP explains about these two variables.
Script_name
Script_filename
It is said that the correct script_filename must be specified and php-cgi ignores script_name (even if its value is set correctly)
or specify special php.ini, set Doc_root, discard path, fix pathinfo, etc.

Script_filename is just being used as a quick way. If the Fix_pathinfo setting is turned on, the INIT function uses it to determine the true path

Because the configuration file changes the Nginx variable $fastcgi_script_name

Fastcgi_param script_name/home/gavin/nginx/$fastcgi _script_name;
Fastcgi_param script_filename $fastcgi _script_name;

And

Fastcgi_param script_filename/home/gavin/nginx/$fastcgi _script_name;
Fastcgi_param script_name $fastcgi _script_name;

Both of these configurations are possible

Use
Fastcgi_param script_filename $document _root$fastcgi_script_name;
It's OK, but you have to make sure $document _root is set correctly.

' Script_filename '
Absolute path name (pathname) of the current execution script
' Script_name '
The path that contains the current script. Useful when pages need to point to themselves. __file__ constants include path and filename

; Cgi.fix_pathinfo provides *real* path_info/path_translated support for CGI. PHP ' s
; Previous behaviour is to the set path_translated to Script_filename, and to not Grok
; What Path_info is. For more information on Path_info, the "the CGI specs." Setting
; This to 1 would cause PHP CGI to fix it's paths to conform to the spec. A setting
; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
; To use Script_filename rather than path_translated.
; Cgi.fix_pathinfo=0

Mainly with the CGI standard
Path_info
Path_translated
Script_name
Have a relationship
Modified a lot.
The final major modification of the

Put NGINX DEFAULT in that file.

Fastcgi_param script_name $fastcgi _script_name;

Change to the actual path

I'm in the same situation today.

Mine is Fastcgi_param script_name/var/www/nginx-default/$fastcgi _script_name;

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.