Laravel 在主页上显示 index.php 的代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42921669/
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 showing code of index.php on home page
提问by Faizan Ali
I'm using Apache 2.4 on Ubuntu 16.04, it shows the content of the index.php in browser.
我在 Ubuntu 16.04 上使用 Apache 2.4,它在浏览器中显示 index.php 的内容。
here's the code of my site's conf file:
这是我网站的 conf 文件的代码:
<VirtualHost *:80>
DocumentRoot /var/www/laravel/public
ServerName laravel.dev
<Directory /var/www/laravel/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Why the home page renders index.php as text file?
为什么主页将 index.php 呈现为文本文件?
Note: I have set 777 permissions to laravel folder. PHP is also installed.
注意:我已经为 laravel 文件夹设置了 777 权限。PHP也安装了。
回答by Faizan Ali
回答by Saurabh Mistry
add below command :
添加以下命令:
sudo apt-get install libapache2-mod-php7.2
(this will pull the default PHP version)
(这将拉取默认的 PHP 版本)
Reload Apache configuration changes by restarting service using below command
通过使用以下命令重新启动服务来重新加载 Apache 配置更改
sudo service apache2 restart