Fixing PHP when upgrading Ubuntu 16.10 to 18.10
So you’ve updated to 18.10 from 16.04 and suddenly your web server is broken. You tried loading up your php based site and you’re either seeing a jumble of flat text that semi-resmebles your site, or worse nothing but a blank page. How do we fix it? It’s not that hard!
First lets check out apache and see if something is happening there:
apachectl configtest
One of three things will happen, 1) you’ll end up with some config error that you can fix in the apache2 conf; 2) Everything is OK; 3) a mod error.
So the errors that I’ve have occur on my servers come mostly from the PHP module either not being loaded properly, the module not being referenced at all, or just some weird bug where it removes itself from any apache references.
apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php7.0.load: <br>Cannot load /usr/lib/apache2/modules/libphp7.0.so into server: <br>/usr/lib/apache2/modules/libphp7.0.so: cannot open shared object file:<br>No such file or directoryAction 'configtest' failed.<br>The Apache error log may have more information.
So I checked /etc/apache2/mods-enabled/php7.0.load and at line 3 it had:
LoadModule php7_module /usr/lib/apache2/modules/libphp7.0.so
But in my /usr/lib/apache2/modules folder I had a newer module, libphp7.2.so. So In /etc/apache2/mods-enabled/php7.0.load I changed it to:
LoadModule php7_module /usr/lib/apache2/modules/libphp7.2.so
But in my /usr/lib/apache2/modules folder I had a newer module: libphp7.2.so. So In /etc/apache2/mods-enabled/php7.0.load I changed it to:
LoadModule php7_module /usr/lib/apache2/modules/libphp7.2.so
Restart apache and it should work.
Now the other issue I’ve had is it removing any references listed in apahce2, so the easy fix was running: sudo a2enmod php7.2
I hope this helps someone who got stuck like I did.