问题描述
我在本地主机上开发了一个laravel应用程序,并且运行正常。我正在尝试在Ubuntu 20.04上使用nginx将其部署到AWS Lightsail实例上。我已经上传了laravel应用,并将nginx根目录更改为laravelapp / public。
主索引页面(着陆页)工作正常,但我的所有路由均不工作(即/ login,/ about等)。当我尝试访问任何一条路线时,都收到404 not found错误。
这是我的Nginx / sites_available /默认文件:
# Default server configuration
server {
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;
}
}
这是我的路线列表的视图:
解决方法
location / {
try_files $uri $uri/ /index.php?$query_string;
}