今天把本地完成的laravel框架代码布置到Nginx上面去,访问路口文件没问题,访问其他的路由就报404。然后查找其他大佬的解决办法,还是很不错的,所以自己写个文章记录下来,好记性不如烂笔头嘛。也可以给各位遇到一样问题的同行解决问题。 (如果你在域名后面加上index.php可以访问,可以用这个方法)
server {
listen 80;
server_name www.51growup.com;//访问这个域名路由404
root /data/wwwroot/default/51growup/public/;
index index.html index.php index.htm;
//加上这个就可以解决了 (*号用作标记,是不需要的哦)
**location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$query_string;
}**
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php7.2-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}