【发布时间】:2019-11-13 18:49:13
【问题描述】:
通过使用NGINX和php-fpm,我想在这样的子目录下添加另一个Yii2高级项目
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
以下是我用于 1 个项目的 nginx 配置 如何修改它以在子目录中添加另一个 Yii2 高级项目?
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;
}
}
【问题讨论】:
-
你了解模块吗?我知道这并不完全是在问你的问题,但模块就像你项目中的“新鲜”项目。 yiiframework.com/doc/guide/2.0/en/structure-modules