目前是这样一个需求,要求把不同的 php 项目部署到相同域名+端口下,也就是部署在不同的子目录。要求最终效果是这样的:
-
http://xxx.com/app1 访问项目 1
-
http://xxx.com/app2 访问项目 2
-
现在的 nginx 配置是这样的,能够正常工作,但是个人觉得写法很恶心,请问大神有优雅点的方式么?
location /app1 {
alias html/php-app1/;
try_files $uri $uri/ @app1;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
location @app1 {
rewrite /app1/(.*)$ /app1/index.php?/$1 last;
}