无法查看或访问 Laravel 的公共文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23760774/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:32:38  来源:igfitidea点击:

Cant see or access Laravel's public folder

phplaravelfedora

提问by totymedli

On Fedora 20 I created a folder named testthen installed Laravel via composer create-project laravel/laravelinto it. It ran successfully and now I try to view it in FireFox in the following URL:

在 Fedora 20 上,我创建了一个名为的文件夹,test然后通过composer create-project laravel/laravel其中安装了 Laravel 。它运行成功,现在我尝试在 FireFox 中通过以下 URL 查看它:

http://localhost/~username/test/laravel/public/

But it throws the following error:

但它抛出以下错误:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。

请通过 root@localhost 联系服务器管理员,告知他们此错误发生的时间,以及您在此错误之前执行的操作。

服务器错误日志中可能提供有关此错误的更多信息。

If I go to the parent folder, I can see that everything is there except the publicfolder. However if I lsin the terminal I can see that the folder is right over there. There is no problem with other PHP scripts only with this project. I tried to play with folder permission but no success. Why can't I see the folder in the browser and why does it throws an Error 500 when I try to access it?

如果我转到父文件夹,我可以看到除了public文件夹之外的所有内容都在那里。但是,如果我ls在终端中,我可以看到该文件夹​​就在那里。其他PHP脚本只有这个项目没有问题。我尝试使用文件夹权限播放但没有成功。为什么我在浏览器中看不到文件夹,当我尝试访问它时为什么会抛出错误 500?

回答by totymedli

Debugging

调试

After I looked at /var/log/httpd/error_logI saw the following in the last line:

看完之后,/var/log/httpd/error_log我在最后一行看到了以下内容:

[Tue May 20 09:37:21.874443 2014] [core:alert] [pid 2897] [client ::1:55498]
/home/username/public_html/test/laravel/public/.htaccess:
Options not allowed here, referer: http://localhost/~username/test/

[2014 年 5 月 20 日星期二 09:37:21.874443] [core:alert] [pid 2897] [client ::1:55498]
/home/username/public_html/test/laravel/public/.htaccess
此处不允许选项,引用者:http://localhost/~username/test/

Make things work

让事情发挥作用

So in my publicfolder I renamed the .htaccessfile to .htaccess2and now it works. Of course now I need to write index.phpafter public/in the URL but at least it works. This also solved the invisible folder error, so if I go to the project root (the parent folder of public) in the browser it lists the publicfolder too.

所以在我的public文件夹中,我将.htaccess文件重命名为.htaccess2,现在它可以工作了。当然,现在我需要写在 URLindex.php之后public/,但至少它有效。这也解决了不可见文件夹错误,因此如果我public在浏览器中转到项目根目录( 的父文件夹),它public也会列出该文件夹。

Try to fix it

尝试修复它

According to this answerconfigurations in the httpd.conffile can be overwritten by other extra files. You should search these files for a line containing AllowOverridelike AllowOverride AuthConfig FileInfoand replace it with AllowOverride All.

根据此答案httpd.conf文件中的配置可以被其他额外文件覆盖。您应该在这些文件中搜索包含AllowOverridelike的行AllowOverride AuthConfig FileInfo并将其替换为AllowOverride All.