为了账号安全,请及时绑定邮箱和手机立即绑定

Laravel 路由在实时服务器上导致 404 错误

Laravel 路由在实时服务器上导致 404 错误

PHP
森林海 2024-01-19 14:45:41
我在本地主机上开发了一个 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


查看完整回答
反对 回复 2024-01-19
  • 1 回答
  • 0 关注
  • 20 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信