nginx - 所有 laravel 项目或某些项目的 Nginx 错误 404
问题描述
目前我正在为 web 服务器开发 laravel 项目和 brew install nginx,但是当我打开它时,我的 laravel 项目出现错误 404。
所以我尾随看看发生了什么
tail -f /usr/local/var/log/nginx/error.log
Output : the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/etc/nginx/nginx.conf:1<br>
*1 directory index of "/Users/user/Projects/new-project/" is forbidden, client: 127.0.0.1
然后我尝试将用户更改为用户 www-data; 正如其他解决方案中所建议的,但仍然无法打开。
user www-data;
worker_processes 1;
events {
worker_connections 1024;
}
server {
listen 8080;
server_name test.localhost;
location / {
root /Users/user/Projects/test;
index index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root /Users/user/Projects/test;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我正在使用 macbook unix 终端 catalina
解决方案
根据 nginx 的 Laravel 文档,
您的根文件夹必须指向项目的公共目录
/path/to/Project/public
推荐阅读
- sed - 使用 sed 命令跳过页脚和页眉
- java - 按开始和结束时间戳搜索和检测对象列表中的重叠
- python - 如何在元类中键入提示动态设置的类属性?
- java - chromedriver的STS maven项目错误
- c# - iTextSharp 基于 SQL Query 编辑 PDF
- android - 带有 CollapsingToolbar 的全屏 SwipeRefreshLayout
- laravel - 创建 laravel api 时需要处理的常见异常有哪些?
- octobercms - 十月CMS媒体路径中的双重主题名称
- xml - 安装 Wix 驱动程序?
- python - 网页抓取:遍历不同的页面总是从第一页返回内容