How to fix Apache showing PHP code instead of executing it?

Spread the love

Sometimes, we want to fix Apache showing PHP code instead of executing it.

In this article, we’ll look at how to fix Apache showing PHP code instead of executing it.

How to fix Apache showing PHP code instead of executing it?

To fix Apache showing PHP code instead of executing it, we need to install the PHP interpreter packages.

To install them, we run

sudo apt-get install php libapache2-mod-php
sudo a2enmod mpm_prefork && sudo a2enmod php7.0
sudo service apache2 restart

on Ubuntu.

We install the packages with

sudo apt-get install php libapache2-mod-php

Then we enable PHP on Apache with

sudo a2enmod mpm_prefork && sudo a2enmod php7.0

Then we restart Apache with

sudo service apache2 restart

Conclusion

To fix Apache showing PHP code instead of executing it, we need to install the PHP interpreter packages.

Leave a Reply

Your email address will not be published. Required fields are marked *