When setting up a Ubuntu 16.04 vhost, Apache will use PHP 7.0.22-2+ubuntu16.04.1+deb.sury.org+4.
However, after trying to resolve some conflicts by doing apt-get dist-upgrade
(and failing), I ended up with a badly broken system. I've since managed to roll back most package versions to those that are default, but Apache uses
PHP 7.1.8-2+ubuntu16.04.1+deb.sury.org+4, which is incompatible with some PHP-libraries I need.
So far, I've tried:
sudo a2dismod php7.1
sudo a2enmod php7.0
sudo service apache2 restart
However, this breaks Apache and it refuses to restart:
Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php7.0.load: Cannot load /usr/lib/apache2/modules/libphp7.0.so
How can I get Apache to run the default PHP version (PHP 7.0) again?
Edit: A comment to my [now redacted] self-answer below by Dan made me realize that having added the following third party PPA ppa:ondrej/php
may have something do do with the problem.
So:
I have added the PPA ppa:ondrej/php
to my site.
I'll split my answer into two parts. The first part describes how your problem occurred, the second part is the actual answer to your issue.
Description
Disclaimer: Most of my description is basically speculation, as I cannot really know what you did. But it's the most likely scenario, as I cannot think of another way that would end up giving you the issue you described.
From the problem you describe, it seems you have installed a third party PPA which installed PHP 7.1 on your system. The most likely PPA is Ondrej's PPA.
When you first installed PHP, you installed in the following method:
The
php
package is only a meta package and does not contain the binaries needed. It depends on the latest version of the available PHP package (by default 7.0). So when you install it, thephp7.0
package is installed along withphp7.0
's dependencies (andlibapache2-mod-php7.0
if you haveapache2
) and all those dependencies are marked in the package manager as "automatically installed".I bolded the parts of the command's result, which explains what I just mentioned.
Ondrej's PHP PPA offers multiple PHP versions that can be installed alongside each other. So when you added it your system,
apt
found a newer version of PHP so it replacedphp7.0
* withphp7.1
along with any related packages that were automatically installed.Answer
There are two methods to fix your issues.
Completely remove the 3rd party PPA, and revert back to the default PHP packages
Ondrej's PPA offers multiple versions of PHP, so you can install more than one version along side each other. But you would enable only the
php7.0
Apache module.Installing them in the previous manner would set the
php7.0
package as "manually installed" inapt
, so they won't get removed automatically without you removing them yourself. Don't forget to make sure to install any PHP modules you need for php7.0 as well (Likesudo apt install php7.0-mysql
)*
php7.0
may have been kept in your system installed if you had manually installed a module specifically for php7.0 (for examplephp7.0-mysql
).By searching packages.ubuntu.com for the file
libphp7.0
, I found two packages containing that file. Is either or both installed?libapache2-mod-php7.0
and/orlibphp7.0-embed
?Reinstalling
libapache2-mod-php7.0
withthen see what there is to read in the package. List the contents with
The search results: