2

I just installed an existing Laravel project onto a web server by git cloning. I have done as much proper setup as possible as per Laravel guidelines, including setting up Apache Virtual Hosts like so:

<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. 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)
  • a2enmod rewrite
  • service apache2 reload
  • modification of .htaccess
  • ensured the loaded page is not a cached one

Resources used:

Community
  • 1
  • 1
Marcel Gruber
  • 6,668
  • 6
  • 34
  • 60

2 Answers2

7

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.

Marcel Gruber
  • 6,668
  • 6
  • 34
  • 60
  • 2
    for php7 i used `sudo apt-get install php libapache2-mod-php php-mcrypt` thank you for the solution btw, it took me 5 hours of research to find you – George Jun 13 '17 at 22:05
  • For specific versions do: `sudo apt-get install -y libapache2-mod-phpVERSION`, replace version with specific php version your project requires i.e. `libapache2-mod-php7.4`. Apache will auto run `a2enmod php7.4` after install. – Dale Ryan Jul 25 '22 at 08:29
1

The command:

a2enmod php7.2

did it for me.