angular - 在同一台服务器上部署 Angular 和 laravel(LEMP 堆栈)
问题描述
所以我有两个目录。一个用于角度,一个用于 laravel。我正在尝试将它们部署在同一台服务器(LEMP 堆栈)上。
这是我的 nginx 配置文件:
server {
listen 80 default_server;
charset utf-8;
location / {
root /var/www/client/;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api {
alias /var/www/server/public/;
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
角度工作正常。该网站已显示,但当我向我提出请求时,/api
我只是得到“未找到”。例如/api/register
不起作用。我究竟做错了什么?
解决方案
可能是重复问题
在“fastcgi_param”之后添加此语句
fastcgi_param REQUEST_URI $request_uri;
Laravel 使用 $_SERVER['REQUEST_URI'] 变量进行路由,并从 fastcgi 传递给 Laravel。
推荐阅读
- pdfbox - 如何使用 PDFBox 从 PDF 文件中删除覆盖?
- c# - 为什么我的 ASP.NET ListBox 没有填充结果?
- python - 如何将两个列表合并到 Python 中的字典中?Dict 和 Zip 不起作用
- r - 使用 mutate() 返回关于无法修改的错误,因为它是一个分组变量
- python-2.7 - 如何在 3D 数组上应用 mean_squared_error
- php - 如何强制客户在 Magento 中注销
- perl - 错过了哪些模块?
- javascript - 为什么括号会导致对象变得未绑定?
- json - 将 Biquery 查询格式化为 ML 适当的 JSON 以通过 ML Predict
- django - 无法从管理员保存 Django 代理用户模型