I am facing the same dreaded "No input file specified." message in NGINX. A brief description of what I am trying to achieve is as given below.
- Any existing URL ending with ".php" extension should show as 404 error [working]
- Any existing URL without ".php" extension will execute the file [working]
- Any non-existent URL should throw 404 error [not working]. In this case the error thrown by NGINX is "No input file specified."
I have visited and tried to implement the solution located at Nginx + php fastcgi showing "No input file specified." instead of 404 but this did not solve my problem.
I am really not sure how to render 404 page in case of point 3.
Contents of /etc/nginx/sites-enabled/default file is given below
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/example.com;
index index.php index.html index.htm;
server_name example.com;
error_page 404 /error/custom_404;
location / {
try_files $uri $uri/ @missing;
}
location ~ (\.php$|myadmin) {
return 404;
}
location @missing {
fastcgi_param SCRIPT_FILENAME "$document_root$uri.php";
fastcgi_param PATH_TRANSLATED "$document_root$uri.php";
fastcgi_param QUERY_STRING $args;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Please keep in mind that I am just a beginner and not an expert. Any help is appreciated.