1.自己新项目laravel框架 配置好后,打开报错404(phpstudy nginx配置)
先把基础的配置配好,然后你的vhosts.conf出现下面这种情况
server {
listen 80;
server_name bo.mooby.com mooby.com;
root "E:\phpstudy\PHPTutorial\WWW\mooby\public";
location / {
index index.html index.htm index.php;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
再location里面少一行代码 try_files $uri $uri/ /index.php?$query_string;
修改代码后:
server {
listen 80;
server_name bo.mooby.com;
root "E:\phpstudy\PHPTutorial\WWW\mooby\public";
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
但是有的人复制了少的哪行代码进去,nginx就会启动不了,这有可能是因为你没有专业的打开文档的软件,你是用winds自带的打开文档方法,所以导致代码被默认的转化了,所以下载一个打开文档不会改变样式的软件,OK了
try_files $uri $uri/ /index.php?$query_string;
本文介绍如何通过正确配置nginx的vhosts.conf文件,解决Laravel项目中出现的404错误,包括添加try_files指令的具体方法。

271

被折叠的 条评论
为什么被折叠?



