PHP file in Ubuntu not rendering properly

As I was done creating my PHP file in my Ubuntu server, I tried loading up the page and the page wasn’t rendering the PHP code correctly. It was rendering my PHP code as a text.

If this is also happening to your website, here are some stuff you can start doing to properly load up your PHP page file on your Ubuntu server.

The first step is to install the necessary packages on your Ubuntu server.

sudo apt-get install apache2 php7.0 libapache2-mod-php7.0

 

It’s good to verify the PHP module is loaded. You can do so by running the code below.

a2query -m php7.0

 

If not enabled, do the following.

sudo a2enmod php7.0

 

Once all those setups are done, the last step is to restart apache.

sudo service apache2 restart

Go to your browser and try loading up the page again. Your page should load up correctly.

Enjoy coding!