I\'ve stuck on simple thing, please help. I have 2 directories with PHP projects: /var/www/api/ and /var/www/api-beta/. I want to forwarding each of them to PHP-FPM. Nginx confi
It may be simpler to create a location
block for each PHP root:
server {
listen 80;
root /var/www/api;
index index.php index.html;
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
location ^~ /beta {
alias /var/www/api-beta;
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
}
Notes:
^~
modifier cause the prefix location to take precedence over the regular expression location above. See this document for more.