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

September 30, 2014 81.3k views

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.

9 Answers

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.

  • Hi, Is it normal that on the phpinfo(); header we have PHP Version It's weird.

  • @FelixINX The header will display the full package version string. 5.6.10 is the upstream PHP version number while is the Debian packaging version.

  • Hi,

    After the second command I get the following error:

    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 92: ordinal not in range(128)

    This is something with the locales I guess.
    This is what I get when doing locale:

    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory

    I tried everything I can find, mainly about setting locales, but nothing seems to be the solution. I also tried it on Ubuntu 14.04 on the RaspberryPi, but it got the same problems.

    It would be great if you could help me with this!

    I am running Ubuntu 14.04 with Apache 2.4.7 (Apache/2.4.7 (Ubuntu)) and PHP 5.5.9 (PHP 5.5.9-1ubuntu4.5 (cli))

  • PPA has a new repository

    sudo add-apt-repository ppa:ondrej/php5-5.6

    is being DEPRECATED. use

    sudo add-apt-repository ppa:ondrej/php

    Also, when installing, use

    sudo apt-get install php5.6 php5.6-fpm php5.6-xml ...
    • Thanks have this installed, but my server is now using both 5.6 and 5.5, php info shows 5.5, is there anyway to get this to point to 5.6

  • I do not install php5-mbstring.
    Help me please!

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

  • This has some key steps the other instructions are missing.

    Without the a2dismod/a2ensmod steps, Apache will continue to see your older version of PHP, even if command line is seeing the new version.

    Thank you Michael!

  • Thank you. This answer has really helped me. You can also use dpkg --get-selections | grep -v deinstall | grep php command to see the PHP packages installed on your server to add them for PHP 5.6 if necessary.

  • Thank you Michael.

  • Works for me, thanks !

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


sudo apt-get install php5 php5-fpm

in the provided sequence of commands

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" when hitting my phpinfo.php page. However, when I invoke "php -v" on the command line, I see:
PHP (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 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache

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

Thank you,

I have followed this guide but seem to have run into problems:

I did the following:

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

Now what seems to have happened is when I check phpinfo.php it is using 5.5.9 but the cli is using 5.6.24

When I use composer install, It seems all my extensions (intl, mbstring, zip etc..) are not installed. I am a bit lost and would really appreciate any advice :-)



  • I have the same problem. phpinfo() shows the previous version of installed php, but php -v in terminal shows the latest one. Did you get a solution to it?

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?

  • I'm facing the same problem. Could anyone help?

    • First, be sure to run:

      sudo apt-get install php5.6-fpm

      Then, in your nginx site config file (here: /etc/nginx/sites-available), change

                  fastcgi_pass unix:/var/run/php5-fpm.sock;


                  fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;

      This is of course, assuming that your info.php is in the same directory as your root site files as configured in the nginx site config file.

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

  • 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'm using NGINX and I'm facing this problem too

Have another answer? Share your knowledge.