On Ubuntu 16.04 LTS Server, after installing nginx
using the package manager, the example PHP location
in /etc/nginx/sites-available/default
includes snippets/fastcgi-php.conf
. This is the contents of that file:
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
It appears that the problem is mitigated by using fastcgi_split_path_info
to get $fastcgi_script_name
and $fastcgi_path_info
. Then try_files
is used to look for $fastcgi_script_name
. If the PHP file does not exist, a 404 Not Found
is returned.
I would be curious to know if this solution is implemented by other distributions.