10

I went through my usual server package upgrades today and discovered that ppa:ondrej/php5-5.6 has been depreciated and we must now upgrade to ppa:ondrej/php.

The basic provided instructions are to run:

sudo add-apt-repository ppa:ondrej/php

And then:

sudo apt-get update
sudo apt-get upgrade --show-upgraded

Looking at the new repository, the names do not seem to completely line up so I think I'll need to do some apt-get installs to get all the right packages installed. It also appears that the sub-packages (ie php-gd) will install for all php versions and may also install php 5.5 and php 7.0 (https://stackoverflow.com/questions/37197539/an-issue-after-ppaondrej-php5-deprecation)

So my question is, what is the cleanest way to "switch" ppas and clean up the existing packages considering that this is a production server? Should I try to remove all the packages installed from the previous PPA and/or remove the PPA from my system?

It's not yet in the main page for the PPA but the upgrade message gave deprecation as June 2016 so it's not a very long timeline to rebuild our server image.

I did find this page, which provides instructions for switching out the PHP version apache uses: https://dzone.com/articles/php-70-and-56-on-ubuntu

  • 1
    I'll write some text on the topic in the repo wiki here: github.com/oerdnj/deb.sury.org/wiki I just need to find a bit of free time. Everyone is welcome to start and contribute meanwhile :) – oerdnj May 17 '16 at 14:51
12

The old php5-* packages are coinstallable with the new phpX.Y-* scheme, so the first thing you need to do is to install and enable new packages:

Apache 2.4

You need to install new libapache2-mod-phpX.Y packages and then disable the old php5, and enable new versioned module, f.e. for PHP 5.6:

sudo apt-get install libapache2-mod-php5.6
sudo a2dismod php5
sudo a2enmod php5.6

NGINX/Apache 2.4 with PHP-FPM

This is even more straightforward, just install phpX.Y-fpm and change the socket path in your webserver configuration to /run/php/phpX.Y-fpm.sock and copy the old configuration, f.e. for PHP 5.6:

sudo apt-get install php5.6-fpm
# now change the socket path in your nginx/apache2 configuration
# and restart the server

If you have defined more FPM pools, you need to copy the old configuration to the new path, again for PHP 5.6:

# keep the new www.conf
sudo mv /etc/php/5.6/fpm/pool.d/www.conf /etc/php/5.6/fpm/pool.d/www-5.6.conf
# copy the old configuration to the new path
sudo cp /etc/php5/fpm/pool.d/* /etc/php/5.6/fpm/pool.d/
sudo update-rc.d php5-fpm disable # or uninstall php5-fpm package
# restart PHP 5.6 FPM to read the new configuration
sudo service php5.6-fpm restart

Now if you want to remove the old packages, you might run into some problems as there might be packages that require old php5* names, you might want to add ppa:ondrej/php5-compat that provide thin layer of compatibility packages that map php5-<foo> to php5.6-<foo> for main php5* packages:

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

Definitely try this first in non-production environment! The good side is that this keeps the old configuration in /etc/php5 untouched, so you can migrate the old settings.

After updating the main PHP packages, you might want to lookup rest of the php5-* packages and install their equivalent, e.g.

apt-get install php-apcu # for php5-apcu
apt-get install php-memcached # for php5-memcached

I'll prepare an update to php5-compat repo, that will make this mappings automatically.

The more up-to-date text, can be always found in the DEB.SURY.ORG PPA Wikis.

  • 1
    Thanks for all your work! We do have a staging server which I'll try everything on first. In your instructions, you may want to include something about running dpkg --get-selections | grep php to list all the current packages to help people map things (though the mapping ppa will be super useful for not having to do that and letting it just work.) It might also be good to include sudo add-apt-repository --remove ppa:whatever/ppa5-5.6 – Loren May 17 '16 at 15:29
  • Good idea with the removal of old PPA. – oerdnj May 17 '16 at 15:33
  • 1
    Hey @oerdnj. Shouldn't it be a2dismod instead of phpdismod there? And a2enmod instead of phpenmod? – Wojtek Naruniec Jul 22 '16 at 17:08
  • Good catch, fixed. – oerdnj Jul 22 '16 at 17:14
  • dbase extension doesn't work with your 5.6 module, I could compile it earlier for old 5.6 version but not for new repository. It gets compiled for old 5.5 version . but 5.6 version is run so lost module. Are there any chances you could somehow not disable old 5.6 ppa? – Tebe Dec 12 '16 at 21:58

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.