Faizan Ali
Faizan Ali

Reputation: 1013

Laravel showing code of index.php on home page

I'm using Apache 2.4 on Ubuntu 16.04, it shows the content of the index.php in browser.

enter image description here

here's the code of my site's conf file:

<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?

Note: I have set 777 permissions to laravel folder. PHP is also installed.

Upvotes: 14

Views: 25957

Answers (3)

A.G.
A.G.

Reputation: 324

I ran into same issue and was looking for answers. In my case I had multiple versions of PHP installed with all necessary libraries, including the one mentioned in answers above.

The cause of issue turned out to be not properly switching between PHP, which I do time to time while switching projects. Running again a2dismod php5.6 and then a2enmod php7.3 (switch from php5.6 to php7.3) and restarting apache did the job for me.

Hope this helps someone with similar issue like mine.

Upvotes: 2

Saurabh Mistry
Saurabh Mistry

Reputation: 13669

add below command :

sudo apt-get install libapache2-mod-php7.2

(this will pull the default PHP version)

Reload Apache configuration changes by restarting service using below command

sudo service apache2 restart

Upvotes: 16

Faizan Ali
Faizan Ali

Reputation: 1013

I got the solution over here..

Actually, I had to install libapache2-mod-php and activate it i.e. a2enmod php7.0

Upvotes: 21

Related Questions