我在本地主機上開發了一個 Laravel 應用程序,并且運行良好。我正在嘗試在 Ubuntu 20.04 上使用 nginx 將其部署到 AWS Lightsail 實例上。我已經上傳了我的 laravel 應用程序并將 nginx 根目錄更改為 laravelapp/public。主索引頁面(登陸頁面)工作正常,但我的路線都不起作用(即/登錄、/關于等)。當我嘗試訪問任何路線時,我收到 404 未找到錯誤。這是我的 nginx/sites_available/default 文件:# Default server configurationserver { listen 80 default_server; listen [::]:80 default_server; root /var/www/investa/public; index index.php index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; }}這是我的路線列表的視圖:Laravel 應用程序路線
1 回答

RISEBY
TA貢獻1856條經驗 獲得超5個贊
location / { try_files $uri $uri/ /index.php?$query_string; }
在這里比較: https: //laravel.com/docs/7.x/deployment#nginx
- 1 回答
- 0 關注
- 215 瀏覽
添加回答
舉報
0/150
提交
取消