php - 如何在 1 个域上提供两个 laravel 应用程序?
问题描述
我有两个这样的 laravel 应用程序:
- apps
- dashboard
- website
我试图在 linux 机器上为它们服务,我似乎无法让它们一起工作。我想要两个这样的网址: https ://test.example.co
https://test.example.co/dashboard
server {
server_name test.example.co;
index index.php index.html index.htm index.nginx-debian.html;
location = / {
root /var/www/example/apps/website;
try_files $uri $uri/ /public/index.php;
}
location ~ ^/dashboard {
root /var/www/example/apps;
try_files $uri $uri/ /dashboard/public/index.php;
#try_files $uri $uri/ /index.html;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/test.example.co/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.example.co/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# pass the PHP scripts to FastCGI server listening on /var/run/php7.4-fpm.sock
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
if ($host = test.example.co) {
return 301 https://$host$request_uri;
} # managed by Certbot
}
解决方案
如果您像这样编写代码,您能告诉我结果是什么:
location ~ ^/dashboard {
root /var/www/example/apps/dashboard/public;
try_files $uri $uri/ /index.php;
}
location = ~ ^/ {
root /var/www/example/apps/website/public;
try_files $uri $uri/ /index.php;
}
我只是交换它。因此它将搜索仪表板,如果用户不在仪表板中,它将检查根目录。
推荐阅读
- c# - 使用自动 JWT 请求简化 Swagger 身份验证
- typescript - 为 d3 比例顺序函数定义类型的问题
- kubernetes - AKS:omsagent-win pod 一次又一次地重新启动
- qt - 在 Flickable 和 PinchArea 内居中图像
- android - Android Firebase auth Twitter 在身份验证后不会重定向
- arrays - 如何在 C 方法中使用指针(字符数组)
- ios - 可以在 Github Actions 上加速 Flutter iOS 构建吗?
- laravel - Npm 使用 Laravel Mix 和 localhost:8080 运行 prod
- asp.net-mvc - 如何使用托管在本地 IIS 上的 Web 应用从 Azure 密钥保管库访问 web.config 中的应用设置和连接字符串等机密
- angular - Ngrx 效果 - 如何调度两个动作?