[英]How do i deploy Laravel 5.7 and Angular 7 on a Nginx on a server
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name example;
location / {
index index.html;
try_files $uri $uri/ /index.html =404;
}
location /api {
root /var/www/html/example/public;
try_files /index.php =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param APP_ENV dev;
fastcgi_pass 127.0.0.1:9000;
}
上面是我的服務器配置,但是只有角度工作,但是laravel無法訪問,它一直顯示未找到
閱讀有關請求處理和使用別名的Nginx文檔之后。 我想出了以下幾點:
server {
listen 80;
server_name example.com;
# This is the "last resort" nginx will direct to when no other matches with location have been found.
# It will only look for a file named index.html
location / {
root /location/of/angular;
index index.html;
try_files $uri $uri/ /index.html;
}
# All requests that start with /api are directed to the laravel location.
# It will only look for a file named index.php
location /api {
alias /location/of/laravel;
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
# All files that end with .php are through fastcgi
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param APP_ENV dev;
fastcgi_pass 127.0.0.1:9000;
}
}
旁注:此功能尚未在工作環境中進行過測試,但可能會在正確的方向上為您提供幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.