Nginx。 Laravel。如何在子文件夹中设置多个端点
Nginx. Laravel. How to set up multiple endpoints in subfolders
我有这样一个项目结构
<root>/public/laravel_app/index.php — Laravel index file
<root>/public/index.php — CraftCMS index file
我想在
加载 CraftCMS 应用程序
https://<domain>
和Laravel应用在https://<domain>/laravel_app
这是我的vhost.conf
server {
listen 443 ssl;
index index.php index.html;
root /var/www/public;
ssl_certificate /var/www/docker/certs/nginx.crt;
ssl_certificate_key /var/www/docker/certs/nginx.key;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
我已经查看了几乎所有相关的 SO 问题并尝试了很多东西,所以,如果可能的话,请发送与我的配置相关的建议。
我不是系统管理员,我是 Apache 用户(它以这种方式工作,无需任何调整),所以如果我遗漏了一些明显的东西,我深表歉意。
改变
location / {
try_files $uri /index.php?$args;
}
至
location / {
try_files $uri $uri/ /index.php?$args;
}
添加 $uri/
告诉 nginx 查找具有 uri 名称的目录。
我认为你应该进行 2 url 重写,因为 laravel_app
有自己的 index.php
用于重写。
server {
...
root /var/www/public;
...
location / {
try_files $uri $uri/ /index.php?$args;
}
location /laravel_app {
try_files $uri $uri/ /laravel_app/index.php?$args;
}
...
}
希望这有效
我有这样一个项目结构
<root>/public/laravel_app/index.php — Laravel index file
<root>/public/index.php — CraftCMS index file
我想在
加载 CraftCMS 应用程序https://<domain>
和Laravel应用在https://<domain>/laravel_app
这是我的vhost.conf
server {
listen 443 ssl;
index index.php index.html;
root /var/www/public;
ssl_certificate /var/www/docker/certs/nginx.crt;
ssl_certificate_key /var/www/docker/certs/nginx.key;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
我已经查看了几乎所有相关的 SO 问题并尝试了很多东西,所以,如果可能的话,请发送与我的配置相关的建议。
我不是系统管理员,我是 Apache 用户(它以这种方式工作,无需任何调整),所以如果我遗漏了一些明显的东西,我深表歉意。
改变
location / {
try_files $uri /index.php?$args;
}
至
location / {
try_files $uri $uri/ /index.php?$args;
}
添加 $uri/
告诉 nginx 查找具有 uri 名称的目录。
我认为你应该进行 2 url 重写,因为 laravel_app
有自己的 index.php
用于重写。
server {
...
root /var/www/public;
...
location / {
try_files $uri $uri/ /index.php?$args;
}
location /laravel_app {
try_files $uri $uri/ /laravel_app/index.php?$args;
}
...
}
希望这有效