A
A
Ayk722017-09-28 13:32:46
PHP
Ayk72, 2017-09-28 13:32:46

How to remove No input file specified?

Hello!
Installed nginx+php-fpm, but when the php file doesn't exist, nginx gives an error No input file specified. And how to remove it and replace it with a regular 404 error?
Thanks to all!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Grigoriev, 2017-10-03
@Sleuthhound

There are several reasons for the No input file specified error:
1. You have not set the SCRIPT_FILENAME variable in the nginx config;
2. An incorrect root argument was specified in the nginx config;
3. The open_basedir variable in /etc/php5/fpm/php.ini or in the php5-fpm pool config contains a path that does not match the root argument in the nginx config;
4. The user with the rights of which php5-fpm is running or a specific php5-fpm pool does not have access rights to the directory or file with the php script;
An example of the correct nginx + php5-fpm config:

server {
....
root /var/www/mysite.com;
index index.php index.html index.htm;

location / {
        try_files $uri $uri/ =404;
}
location ~ \.php$ {
        try_files $uri = 404;
        fastcgi_pass unix:/var/lib/php5-fpm/mysite.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
}
...
}

A
Alexander Aksentiev, 2017-09-28
@Sanasol

php.ini
cgi.fix_pathinfo = 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question