Question

How to upgrade from PHP v.5.5.9 to v.5.6

  • Posted September 30, 2014

I just deployed a new droplet. By default, it’s set up with PHP 5.5.9. I would like to upgrade that to v.5.6.

How do I do this?

Thanks in advance.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml sudo a2dismod php5 sudo a2enmod php5.6 sudo service apache2 restart

To upgrade to a newer version of PHP 5.6 on Ubuntu 14.04, you can use Ondřej Surý’s PPA. He is one of the Debian maintainers of the php5 package. To add the PPA and upgrade your packages, run:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5

Though remember to be careful when doing an upgrade of PHP outside of the normal distro repositories, some of the additional modules that you might rely on could be missing for that version.

sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install -y php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip libapache2-mod-php5.6

sudo a2dismod php5 sudo a2enmod php5.6 sudo service apache2 restart

I followed your instructions but keep getting E: Couldn’t find any package by regex ‘php5.6’

How to fix this?

I have an eCommerce site set-up and running on my DO droplet. I want to upgrade this software however, upgrade requirements state that I should also upgrade to PHP 5.6. While it’s not clear as to why this software now needs PHP 5.6, I did notice an issue with how my droplet reports which version of PHP it’s using.

I now see “PHP Version 5.6.23-1+deprecated+dontuse+deb.sury.org~trusty+1” when hitting my phpinfo.php page. However, when I invoke “php -v” on the command line, I see: PHP 7.0.8-4+deb.sury.org~trusty+1 (cli) ( NTS ).

I believe 5.5.x, 5.6.x, and 7.0.x versions of PHP can all live together on the same server, how do I ensure Apache is serving up my site with a non-deprecated version of PHP 5.6?

Please note that phpinfo shows my loaded configuration file is /etc/php5/apache2/php.ini so that seems correct.

LAMP stack versions:

  • Ubuntu 14.04.4 LTS (GNU/Linux 4.4.0-28-generic x86_64)
  • Apache 2.4.7
  • MySQL 14.14 Distrib 5.5.49, for debian-linux-gnu (x86_64) using readline 6.3
  • PHP 7.0.8-4+deb.sury.org~trusty+1 (cli) ( NTS ) Copyright © 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright © 1998-2016 Zend Technologies with Zend OPcache v7.0.8-4+deb.sury.org~trusty+1

Is there an easier way to enforce which version of PHP my server utilizes?

Thank you, _rs

note that if you are using NGINX and not Apache, this needs to be changed to avoid apache being loaded as part of the install. According to the maintainer of the ppa, the correct approach is to replace

sudo apt-get install php5

with

sudo apt-get install php5 php5-fpm

in the provided sequence of commands

I’m using NGINX and I’m facing this problem too

I have a problem as I updated my php version to 5.6 from 5.5. Server:

  • OS: Ubuntu 14.04.1 LTS.
  • Server version: Apache/2.4.7 (Ubuntu).
  • PHP version: 5.5.
  • Laravel 4.2 with yajra package.

I have done the following steps:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml
sudo a2dismod php5
sudo a2enmod php5.6
sudo service apache2 restart

After that, I checked oci8 extensions:

cat /etc/php5/cli/php.ini | grep extension=oci8 => exists
cat /etc/php5/apache2/php.ini | grep extension=oci8 => exists

But the following errors occurs when I load my web on the browser. 2017-01-09 20:13:54] production.ERROR: exception ‘Symfony\Component\Debug\Exception\FatalErrorException’ with message ‘Call to undefined function Yajra\Pdo\oci_connect()’ in /var/www/****/vendor/yajra/laravel-pdo-via-oci8/src/Pdo/Oci8.php:449

How to solve this problem? Is there any idea, please…

I am using NGINX but in the info.php the version is: 5.5.9

and in the cli I have: php-fpm5.6 and php-fpm ¿how do I choose the correct version to load with nginx?