Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Mark Hayes -
Number of replies: 24
Struggling to find a process for doing this without getting into a twist.
Lots of conflicting information out there.

What I have found so far:

# get the PPA 

>sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php          // LC_ALL needed for non UTF-8 locales.
>sudo apt-get update

# see which php-extensions are currently installed

>dpkg --get-selections | grep php

# Question:
# the list shown from the above command is not the same as the list of required extensions shown in
# moodle > admin > server > environment

# So, in the next command, should the list of extensions be the ones that moode needs, plus any that are already installed but which moodle is not using?

>sudo apt-get install php5.6 + extensions...

# do the upgrade

>sudo apt-get update
>sudo apt-get upgrade

# I think the following is needed only if you are migrating from old PPA to new PPA?

sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php5-compat
sudo apt-get update
sudo apt-get dist-upgrade

# Tell apache2.4 to use the PHP5.6 version

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

# Restart apache2

>sudo service apache2 restart

Average of ratings: Useful (1)
In reply to Mark Hayes

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Matt Bury -
Picture of Plugin developers

Hi Mark,

I'm having similar issues. A lot of the instructions I've found for upgrading to PHP 5.6 on Ubuntu 14.04 seem to be out of date, i.e. the PPA for php5-5.6 is no longer there.

As far as I can tell, ppa:ondrej/php5-compat is for compatibility with older versions of Ubuntu (12.04?). See: https://launchpad.net/%7Eondrej/+archive/ubuntu/php It also says that they're co-installable versions so presumably we'd have PHP 5.5 running alongside PHP 5.6 and 7?

Some advice or up-to-date instructions would be appreciated smile

In reply to Matt Bury

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Mark Hayes -

Thanks for your reply Matt.

  1. Yes, the PPA should be ppa:ondrej/php (as stated in the link you provided; this is the PPA I am planning to use).

  2. As for the ppa:ondrej/php5-compat repository:
    Ondřej Surý says:
    "Add this repository if you want to use new PHP packages from ppa:ondrej/php, but for dependency reasons you still need old php5* packages."
    I don't know if there is anything on my system that would still need the old php5* packages.
    Is it benign to add this compat repo?  No idea.

  3. Do the commands that I listed in my original post align with what you have been able to uncover?

Like you, I am finding it difficult to get any confidence from what I am reading; information is either obsolete or conflicting.
I am thinking to Ghost the server and try what I have; if it goes haywire I can fall back to the previous image.

Average of ratings: Useful (1)
In reply to Matt Bury

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Mark Hayes -

I just sent a message to Ondřej Surý; I got his email address by logging into LaunchPad.

Not sure if he entertains these sorts of inquiries; let's see.

Average of ratings: Useful (1)
In reply to Mark Hayes

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Matt Bury -
Picture of Plugin developers

Hi again,

I'm currently trying out Moodle 3.2 on Ubuntu 16.04 which uses PHP 7 by default. So far, it's installed and everything seems to be running smoothly even after installing some 3rd party plugins (no errors reported).

If this works out, I think it'll be easier, for me at least, to set up and support systems this way. It's always a bit nerve racking being on the bleeding edge with few or no other people sharing their experiences and advice!

Thanks for raising this question. I'll be following to see how it turns out smile

In reply to Matt Bury

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Mark Hayes -

The latest and greatest stuff is always more fun.

But I thought Moodle HQ had said to hold off on running moodle on php7.

Would be eager to know how you get on with it.

Average of ratings: Useful (1)
In reply to Mark Hayes

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I've been using PHP 7 on Centos 7 for about a year now with Moodle 3.0, Moodle 3.1, and now Moodle 3.2, without any problems except an occasional plugin that is not updated for PHP 7. Haven't had any plugins not work, just a few warnings due to required changes for PHP 7 that have not been implemented yet. Admittedly, not a bunch of traffic as I am retired and these sites are just for trying things out and keeping up to date on Moodle capabilities.

Average of ratings: Useful (2)
In reply to Matt Bury

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Mark Hayes -

Here is some info on moodle + php7.

It also says, Moodle 3.2 will be compatible with PHP7.1

Average of ratings: Useful (1)
In reply to Mark Hayes

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Mark Hayes -

I got a reply from Ondřej Surý and he thought the steps I posted were correct.

With respect to:

# see which php-extensions are currently installed
>dpkg --get-selections | grep php

he replied:

Using more specific: `dpkg --get-selections | grep php5` would produce
less packages.

Average of ratings: Useful (1)
In reply to Matt Bury

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Mark Hayes -

Here is the final set of commands I used to upgrade php5.5 to 5.6 on ubuntu 14.04
The upgrade seems to be have worked ok.

Thanks to Ondřej Surý for his feedback and help with the script.

PHP 5.6 on ubuntu 14.04

# get the PPA 

>sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php          // LC_ALL needed for non UTF-8 locales.
>sudo apt-get update

# see which php-extensions are currently installed

>dpkg --get-selections | grep php5

# I installed the 5.6-version of all the php5 extensions reported in the above command.
# There are a more php_extensions shown in -
# moodle > admin > server > environment
# which I did not include in the following command.

>sudo apt-get install php5.6 php5.6-cli php5.6-common php5.6-curl php5.6-gd php5.6-intl php5.6-json php5.6-ldap php5.6-mcrypt php5.6-mysql php5.6-readline php5.6-xmlrpc

# do the upgrade

>sudo apt-get update
>sudo apt-get upgrade

# The following is needed only if you are migrating from old PPA to new PPA?

>sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php5-compat
>sudo apt-get update
>sudo apt-get dist-upgrade

# Tell apache2.4 to use the PHP5.6 version

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

# Restart apache2.4

>sudo service apache2 restart

Average of ratings: Useful (4)
In reply to Mark Hayes

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Matt Bury -
Picture of Plugin developers

Thanks Mark, you're a star! smile

In reply to Mark Hayes

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Ryan B -

Thanks for the directions. Everything worked great, even though I'm on 16.04.

Now php -v shows PHP 5.6.29-1+deb.sury.org~trusty+1 (cli) and the PHP info on Moodle shows the correct version.

However, going to "Environment" on moodle leads to a blank page. No output at all. It was working correctly earlier, so I'm not sure what broke it. Any ideas?

Moodle 3.1.2, Ubuntu 16.04.1

Thanks

In reply to Ryan B

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Randy Thornton -
Picture of Documentation writers


Ryan,

I had this same issue, and turned out to be that several of the xml mods were not present in Ondrej's 5.6 ppa. So I had to apt-get mod_xml, mod_simplexml, and mod_xmlprc, then the Environment page loaded for me ok.

Randy



Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Ryan B -

Thanks. Yes, I had to reinstall a couple mods and it is now all working perfectly.

In reply to Mark Hayes

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Bret Miller -
Picture of Particularly helpful Moodlers

So I use FastCGI, not mod_php, but the process is probably similar:

sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php5.6 php5.6-mcrypt php5.6-cgi php5.6-cli php5.6-curl php5.6-xmlrpc php5.6-gd php5.6-intl php5.6-json php5.6-mbstring php5.6-mysqli php5.6-xml php5.6-zip -y

Until today, I was using PHP 5.6 on Moodle except for the test site. But today I upgraded to the current 3.0.x branch and PHP 7.0.

Average of ratings: Useful (1)
In reply to Mark Hayes

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

While in no way detracting from the work you have put into this (I got completely stuck too!) I wonder if it is a lot less stress just to upgrade to 16.04 and run PHP7? I have done that on a couple of my test/demo servers with no issues whatever. So far wink

In reply to Howard Miller

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Randy Thornton -
Picture of Documentation writers

Howard,

What version of MySQL are you running on that?

My only hesitation in going to 16.04 & 7 has been the possible database versioning issues. I believe it will upgrade you to MySQL 5.7.

I have a couple really old sites (M 1.9 & 2.2) that are archived away but I still need occasional access to & don't want to have to mess with complication of multiple db versions etc... so not sure how those would fare with MySQL 5.7

In reply to Randy Thornton

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I'm running 5.7 on that box but I don't have anything older than 3.1.  We have some production servers running MySQL 5.7 and PHP 5.6. They are running some 2.9 sites I think - with no issues. Nothing older.

In reply to Howard Miller

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Randy Thornton -
Picture of Documentation writers

Thanks, Howard, that makes sense. I do have some old, archived sites I have to maintain not for active users but for client staff who need to go in occasionally and get things (reports, certificates etc). But I am not sure I want to take the time to wrangle it. I was thinking to go - as Matt suggested below - with just building another instance altogether based on 16.04 and go forward with it.

In reply to Randy Thornton

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Randy Thornton -
Picture of Documentation writers

FYI

Just wanted to follow up and note that on Ubuntu 16.04 with PHP 7.0 and MySQL 5.7 that I am able to run the following releases: 2.8, 2.9, 3.0, 3.1 and 3.2.

2.8 and 2.9 will warn you in Server > Environment that PHP 7 is not supported, but after a cursory look around, most things work. The pre-Dashboard My is broken in 2.8 and there's a fair amount of debug messages re PHP but overall things are working. I'm sure more things will be wacky, but these are not production sites, I just wanted to check it out to see if it would work at all.

2.7 tries to load by doesn't render the whole page properly (using Clean with Debugging Full on). It's dead, Jim. Not sure of exact cause but also not inclined to investigate since it all works on 14.04 and I am keeping that instance for older releases needing PHP 5.

3.0 onwards seems to be good with PHP 7 so far for me.



In reply to Randy Thornton

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Mark Hayes -

Thanks for that feedback Randy.
I have been eager to go to Ubuntu 16.04 LTS but have held back due to PHP 7; good to know that M seems to be stable on it.

In reply to Randy Thornton

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Matt Bury -
Picture of Plugin developers

Hi Randy,

These days renting VPS' is cheap and you can pay by the hour. If you start with a bare Linux instance, you can install whatever LAMP stack you want on it for restoring old backups, trying out archived courses, testing compatibility, etc.. They also usually offer a variety of older versions of flavours of Linux with the corresponding AMP versions of software automatically installed for added convenience - I guess there's a lot of demand for older environments for legacy projects. I think it's quicker, less work, and reasonably reflective of real-world server instances and environments too.

I hope this helps smile

In reply to Matt Bury

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Randy Thornton -
Picture of Documentation writers

Matt,

You read my mind smile In fact, I was thinking about doing this very thing with a fresh 16.04 LTS instance and just go forward from there and leave my 1.9/2.x sites on the 14.04, though eventually it will go out of support, it's got maintenance for a couple more years.

In reply to Howard Miller

Re: Upgrading PHP5.5 to 5.6 on Ubuntu 14.04 LTS

by Mark Hayes -

Hi Howard-

My initial thinking was to just bump php on 14.04. As things got unexpectedly complicated it did occur to me to just go to 16.04

I guess I just got stubborn. I hate to lose and wanted to crack it. Much like the guy who hits himself over the head with a hammer because it feels so good when he stops.

Average of ratings: Useful (1)