I am running Ubuntu 18.04. I have a LAMP setup. At some point, I realized that my PHP was no longer working. I haven't used it for a while, so unfortunately I can't say when it stopped working. It could well have been when I upgraded to Ubuntu 18.04 from 16.04.
I have scoured the Internet looking for answers to the problem and simply haven't been able to get it working. Here's information about the problem and what I have tried:
I reinstalled Apache2. Apache by itself is working, but PHP via Apache is not working: .php files display the code rather than execute it. Or sometimes the .php page is simply blank except for the html on the page. The page with the phpinfo(); function on it is blank.
I am testing by using a .php page with this code:
<h1>My PHP Info Page</h1>
I am accessing this page via the Chrome browser: http://localhost/~username/Testing/info.php
Only the phrase "My PHP Info Page" shows up. The rest of the page is blank.
I am using php7.2.
When I type "php -v" in the terminal, I get:
PHP 7.2.24-0ubuntu0.18.04.10 (cli) (built: Oct 25 2021 17:47:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.10, Copyright (c) 1999-2018, by Zend Technologies
I have run these commands in the terminal at various points:
sudo a2dismod mpm_event && sudo a2enmod mpm_prefork && sudo a2enmod php7.2
sudo a2enmod php7.2
sudo a2dismod php7.0
sudo a2dismod php5
I've added the following code to the apache2.conf file:
I then changed it to:
(I then changed it back. Also, per one suggestion somewhere I manually typed this code in rather than copying and pasting it.)
Each time after making any changes to the apache2.config file, I have restarted the Apache service with this command:
sudo systemctl restart apache2
I'm at my wits end. Why is my PHP not working?