By usng NGINX and php-fpm, I want to add another Yii2 advance project under sub-directory like this
www.xyz.net - frontend project A, root at /var/www/html
www.xyz.net/admin - backend project A, root at /var/www/html
www.xyz.net/old - frontend project B, root at /var/www/old
www.xyz.net/old/admin - backend project B, root at /var/www/old
The below is the nginx configuration which I am using for 1 project How can I modify it for adding another Yii2 advance project in sub-directory?
server {
server_name www.xyz.net;
listen 80;
set $base_root /var/www/html;
root $base_root;
charset utf-8;
index index.php index.html index.htm;
client_max_body_size 128M;
location / {
root $base_root/frontend/web;
try_files $uri $uri/ /frontend/web/index.php$is_args$args;
location ~ ^/assets/.+\.php(/|$) {
deny all;
}
}
location /admin {
alias $base_root/backend/web/;
location = /admin/ {
return 301 /admin;
}
location = /admin {
try_files $uri /backend/web/index.php$is_args$args;
}
try_files $uri $uri/ /backend/web/index.php$is_args$args;
location ~ ^/admin/assets/.+\.php(/|$) {
deny all;
}
}
location ~ ^/.+\.php(/|$) {
rewrite (?!^/((frontend|backend)/web|admin))^ /frontend/web$uri break;
rewrite (?!^/backend/web)^/admin(/.+)$ /backend/web$1 break;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $fastcgi_script_name =404;
}
location ~ /\. {
deny all;
}
}