Ubuntu – Ubuntu 14.04: problems upgrading php to 5.6 using ppa:ondrej

14.04PHPppa

I've done the following:

sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5.6
sudo add-apt-repository ppa:ondrej/apache2

When I try to disable the old version of php5 with:

sudo phpdismod php5

I get the error:
WARNING: Module php5 ini file doesn't exist under /etc/php/5.6/mods-available

Even if I move the ini file under this directory it gives me the same error. I don't know what I'm missing??

In general, can someone explain to me how to get my instance to use the newly installed version, as I still seem to have both php directory trees on my instance. php5/.. and php/5.6

Best Answer

You are mixing different PPAs and versions and commands in incompatible way, let's break it down:

  1. libapache2-mod-php5.6 is present in ppa:ondrej/php and this is really the PPA you want to be using

  2. phpdismod is a command for disabling PHP extensions, and not to manage Apache2 modules, you need a2dismod for that

  3. The PHP Apache2 module in ppa:ondrej/php5-5.6 is named libapache2-mod-php5

So the correct would be:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get purge php5-common # remove and purge old PHP 5.x packages
sudo apt-get install libapache2-mod-php5.6

If you don't uninstall php5-* packages first, you need to disable the php5 module and enable php5.6 module:

sudo a2dismod php5
sudo a2enmod php5.6

And optionally add Apache2 repository:

sudo add-apt-repository ppa:ondrej/apache2
sudo apt-get update
sudo apt-get dist-upgrade

There's a migrationg guide available for PPA packages.

Related Question