我正在单个域的子文件夹下设置多个 Laravel 应用程序(社交网络应用程序,需要 https,单个证书)。
无法弄清楚如何编写 nginx 配置以将 HTTP 请求映射/app1/
到 Laravel 安装/var/www/other_folder/public/
这是配置测试的最新迭代。调试日志被省略。Laravel 根位置 /app1/ 有效,但路由映射 ( /app1/api/method/
) 无效。请帮助,如何调试 nginx 如何逐步处理请求(调试日志不是那么解释),或者给我一个提示如何将子文件夹映射/app1/...
到index.php
Laravel。
server {
listen 80;
server_name apps.mydomain.com;
root /var/www/apps.mydomain.com/docs;
location / {
index index.html index.php;
}
location /app1 {
alias /var/www/other_folder/public;
index index.php index.html;
try_files $uri $uri/ /app1/index.php$is_args$args /app1/index.php?$query_string;
}
location ~ /app1/.+\.php$ {
rewrite ^/app1/(.*)$ /$1 break;
include /etc/nginx/fastcgi.conf;
fastcgi_param SCRIPT_FILENAME /var/www/other_folder/public$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass php;
# Database access parameters
fastcgi_param DB_HOST "localhost";
fastcgi_param DB_USER "apps";
fastcgi_param DB_PASS "xxxxxxxx";
fastcgi_param DB_NAME "app1";
}
# Other locations skipped
include /etc/nginx/global/php.conf; # other php scripts
}