Laravel 应用程序显示文件列表而不是“Hello Page”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28416094/
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
Laravel Application Displays List of Files Instead of "Hello Page"
提问by krifur
I've just started working with Laravel 5, but I've been unable to show the classic Hello page yet; I only see a listing of my application files.
我刚刚开始使用 Laravel 5,但我还无法显示经典的 Hello 页面;我只看到我的应用程序文件的列表。
I've tried to change my .htaccess file, clear my cache, create a new app, but to no avail. I know PHP works fine on my server, it's only this one Laravel application that can't seem to handle it. This seems like I'm missing some obvious thing, but I don't know enough to know what I should be asking.
我尝试更改我的 .htaccess 文件、清除缓存、创建新应用程序,但无济于事。我知道 PHP 在我的服务器上运行良好,只有这个 Laravel 应用程序似乎无法处理它。这似乎我错过了一些明显的事情,但我不知道我应该问什么。
Here's a screenshot to demonstrate what I see:
这是一个屏幕截图来演示我所看到的:
and here's the command I used to created the app
这是我用来创建应用程序的命令
$ laravel new m6g
I'm working on a Mac with the stock apache2 (not set with mamp)
我正在使用股票 apache2 的 Mac(未设置 mamp)
采纳答案by castis
So, technically Laravel isn't 'not interpreting PHP' Laravel doesnt interprent PHP, the PHP engine interprets PHP.
所以,从技术上讲,Laravel 不是“不解释 PHP”,Laravel 不解释 PHP,PHP 引擎解释 PHP。
You have apache configured to serve things only from 127.0.0.1/localhost and you're using apache to browse folders on your machine at the moment.
您已将 apache 配置为仅从 127.0.0.1/localhost 提供服务,并且您目前正在使用 apache 浏览您机器上的文件夹。
Apache should be configured (possibly with a VirtualHost) to point to /m6g/public. At which point apache will see your index.php file and put it through PHP.
Apache 应该配置(可能使用VirtualHost)指向 /m6g/public。此时 apache 将看到您的 index.php 文件并将其放入 PHP。
回答by codeforce
Have you tried to mount your app from the terminal?
您是否尝试过从终端挂载您的应用程序?
First, go to the folder on the terminal using cd and
首先,使用 cd 转到终端上的文件夹
Then run the following command:
然后运行以下命令:
php artisan serve
then you will be able to access your app from http://localhost:8888
然后您将能够从http://localhost:8888访问您的应用程序
回答by Julien
I fixed the same issue on my project by increasing privileges on storage directory. The following command should fix your problem.
我通过增加存储目录的权限在我的项目中解决了同样的问题。以下命令应该可以解决您的问题。
chmod 777 -R storage