Setting up php on ubuntu and apache2

Hi I am trying to use php on Ubuntu 20.04.2 LTS, but im having issues trying to get basic php file to run properly(when i open http://192.168.1.142/info.php but all I see is the php code) I have php 8 running and apache2 is running.

this is the code
<?php

phpinfo();

?>

any help would be great I am trying to use google but not really getting anywhere.

Have you installed mod-php for apache?

sudo apt install libapache2-mod-php
sudo a2enmod php8.0
sudo apache2ctl graceful

These commands will install the apache module to handle PHP; enable the module; and restart apache so that the changes take effect.

thank you I got fed up with it all so re installed ubuntu and installed using Apache friends and all seems to be working.

Sponsor our Newsletter | Privacy Policy | Terms of Service