新的 Laravel 安装在 Nginx 中显示 403 Forbidden
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23507423/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fresh Laravel install displays 403 Forbidden in Nginx
提问by Hoang Lam
I have created a fresh Laravel application by using composer create-project
command. Then I put all the folders and files in /usr/share/nginx/html/
, which is the default document root for my nginx server. However everytime I runs the http://localhost
, it keeps displaying 403 Forbiden
. I tried creating a testing index.php (<? php_info();)
and it worked fine.
我使用composer create-project
命令创建了一个新的 Laravel 应用程序。然后我把所有的文件夹和文件都放在/usr/share/nginx/html/
,这是我的 nginx 服务器的默认文档根目录。但是,每次我运行时http://localhost
,它都会显示403 Forbiden
. 我尝试创建一个测试index.php (<? php_info();)
,它运行良好。
I've read somewhere that I need to set the containing folder (/html), as well as the app/storage
folder permission to 777 but still no luck.
我在某处读到我需要设置包含文件夹 (/html) 以及app/storage
文件夹权限为 777 但仍然没有运气。
Please help me. Thank you in advance.
请帮我。先感谢您。
Here is the nginx default.conf
这是nginx default.conf
回答by Alex
Laravel projects serve from the <projectName>/public
directory. Make sure your nginx config is set up to look there for your index file and NOT in your <projectName>
folder only.
Laravel 项目从该<projectName>/public
目录提供服务。确保您的 nginx 配置设置为在那里查找您的索引文件,而不是<projectName>
仅在您的文件夹中。
回答by Kairee
Would you edit your question and paste your server config there?
您会编辑您的问题并将您的服务器配置粘贴到那里吗?
I think it may because index.php is not in the index file list. check these lines:
我认为可能是因为 index.php 不在索引文件列表中。检查这些行:
index index.html index.php;
or
或者
try_files $uri $uri/ =404;