Nginx + PHP-FPM URI alias and multiple php directories
Your nested location ~ \.php$
block will not find your PHP scripts. The $document_root
is set to /path/to/php-app
. And $fastcgi_script_name
is the same as $uri
which still includes the /app
prefix.
The correct approach is to use $request_filename
and remove your bogus root
statement:
location ^~ /app {
alias /path/to/php-app;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
Always include fastcgi_params
before any fastcgi_param
statements to avoid them being silently overwritten by the contents of the include file. See this document for details.