简体   繁体   English

Laravel public / index.php显示为纯文本

[英]Laravel public/index.php displays as plain text

I just installed an existing Laravel project onto a web server by git cloning. 我只是通过git clone将现有的Laravel项目安装到Web服务器上。 I have done as much proper setup as possible as per Laravel guidelines, including setting up Apache Virtual Hosts like so: 我已经按照Laravel指南进行了尽可能多的正确设置,包括像这样设置Apache虚拟主机:

<VirtualHost *:80>
    ServerAdmin email@gmail.com

    DocumentRoot /var/www/html/project/public

    <Directory "/var/www/html/project/public">
       AllowOverride all
       RewriteEngine On
       RewriteBase /var/www/project/public
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I have also set up directory ownership / file permissions to the best of my ability. 我还尽力设置了目录所有权/文件权限。 However, when visiting the website, the contents of public/index.php are displayed instead of the website being loaded. 但是,在访问网站时,显示的是public / index.php的内容,而不是正在加载的网站。 I know this has certainly been addressed somewhere before, and I apologize if that's the case, but I haven't been able to find clear answers. 我知道以前肯定已经解决了这个问题,对于这种情况,我深表歉意,但是我一直没有找到明确的答案。 Much appreciated. 非常感激。

Other things I have done: 我做过的其他事情:

  • installed php (it came loaded with the server and is version 5.5.9) 安装的php(服务器上已加载,版本为5.5.9)
  • a2enmod rewrite a2enmod重写
  • service apache2 reload 服务apache2重新加载
  • modification of .htaccess .htaccess的修改
  • ensured the loaded page is not a cached one 确保加载的页面不是缓存的页面

Resources used: 使用的资源:

This command fixed my problem: 这个命令解决了我的问题:

apt-get install php5 libapache2-mod-php5 php5-mcrypt

I suppose that this is a duplicate question because it is php related, but this may be helpful to keep around as it is in the context of Laravel. 我认为这是一个重复的问题,因为它与php有关,但是在Laravel上下文中,这可能会有所帮助。

The command: 命令:

a2enmod php7.2

did it for me. 为我做了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM