PHP 7 came out yesterday and I would like to give it a try.

PHP 7.0.0 comes with a new version of the Zend Engine, numerous improvements and new features such as

  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6
  • Significantly reduced memory usage
  • Abstract Syntax Tree
  • Consistent 64-bit support
  • Improved Exception hierarchy
  • Many fatal errors converted to Exceptions
  • Secure random number generator
  • Removed old and unsupported SAPIs and extensions
  • The null coalescing operator (??)
  • Return and Scalar Type Declarations
  • Anonymous Classes
  • Zero cost asserts

Is that possible to install it on current Ubuntu version?

Is there any current limitations or known compatibility issues?

up vote 172 down vote accepted

You can do the following:

sudo apt-get install python-software-properties software-properties-common
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update

Optionally purge PHP 5:

sudo apt-get remove php5-common -y

Or directly purge it including configuration files:

sudo apt-get purge php5-common -y

And finally install PHP 7:

sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y

Optionally clean up unneeded packages afterwards:

sudo apt-get --purge autoremove -y

Alternatively, you can install PHP 7.0 from sources using this script script or following instruction on this blog.


PHP5 has now been replaced with PHP7 as the default PHP in Ubuntu 16.4 so, to install PHP7 on Ubuntu 16.04:

sudo apt-get install php7.0 


sudo apt-get install php
  • 11
    Who is in charge of the ppa? Is it officially supported by zend? – k0pernikus Dec 4 '15 at 18:36
  • 19
    @k0pernikus Zend does not officlally support anything beyond their Zend Server :-) Official Ubuntu packages are supported by Ubuntu's maintainers. This PPA is a personal effort by Ondřej Surý. Ondrey is the official owner of the PHP tree in Debian, which is upstream from Ubuntu. See here: – Palantir Dec 5 '15 at 17:37
  • 4
    Anyway, his PHP PPAs are very popular, to the point where the official Magento distribution advertises the 5.5 and 5.6 version:… – Palantir Dec 5 '15 at 17:38
  • 3
    JFTR memcached isn't upstream ready for PHP 7.0 yet. I haven't looked at memcache, still ironing out smaller bugs after major rewrite of packaging scripts. – oerdnj Dec 9 '15 at 9:42
  • 4
    @Xeridea Try sudo apt-get install libapache2-mod-php7.0, then sudo a2enmod php7.0 then restart Apache – andrewtweber Dec 13 '15 at 19:37

You have two options:

  • Wait until there is a new Ubuntu release that includes PHP7

    Ubuntu won't release major new version releases to most software to existing Ubuntu versions; to get a major new version release you would need to wait until a newer version of Ubuntu.

  • Install a third-party version, such as from a PPA

    PPAs are not bound by the release schedules or policies of Ubuntu so they are free to change versions more frequently, among other things. The PPA mentioned in Tshilidzi Mudau's answer is a popular way of staying more up to date with PHP.

    sudo add-apt-repository ppa:ondrej/php

    PPAs don't come with the same official Ubuntu support as Ubuntu-supplied versions, and due to different schedules and policies may be of a different quality or security standard. In this case, the developer who makes this PPA available is well-known to the community here.

  • 1
    And the option to install from source. – j0h Feb 8 '16 at 19:30

Here is my list of commands to fully update PHP with its dependencies, including phpMyAdmin (full LAMP stack):

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php-7.0
sudo apt-get update
sudo apt-get purge php5-fpm
sudo apt-get install php7.0-cli php7.0-common libapache2-mod-php7.0 php7.0 php7.0-mysql php7.0-fpm php7.0-curl php7.0-gd php7.0-bz2

Now you have PHP7. Let's go for phpMyAdmin: (start here if you have already PHP7 installed)

cd /var/www/html/
sudo wget
sudo unzip
sudo mv phpMyAdmin- phpmyadmin/
sudo mkdir -m 777 phpmyadmin/config/
sudo /etc/init.d/apache2 restart
  • 3
    libapache2-mod-php7.0 is exactly what i needed, thanks! – Jacer Omri Apr 27 '16 at 14:08

For Ubuntu 16.04, PHP7 is now the default official upstream version.

sudo apt install php

Here's a handy guide for setting up a LAMP stack on 16.04.

The above process did not work for my Ubuntu 15.10 server so I thought I would share what did work in case others find it helpful.

First I had to remove certain key PHP 5 modules:

sudo apt-get -y purge php5 libapache2-mod-php5 php5 php5-cli php5-common php5-curl php5-gd php5-imap php5-intl php5-json php5-mcrypt php5-mysql php5-pspell php5-readline php5-sqlite

Then remove a few extra things that were left behind:

sudo apt-get autoremove

Then install PHP 7.0:

sudo apt-get install php7.0

Then as PHPMyAdmin was removed Apache2 wouldn't start so I had to remove the config file (I could have moved it instead):

sudo rm /etc/apache2/conf-enabled/phpmyadmin.conf

Then I had to restart Apache2:

sudo service apache2 restart

PHP 7.0 was then running (confirmed with PHPINFO();)

However I have found the only way to get PHPMyAdmin working is to install/upgrade it manually as otherwise the latest version available in the sources doesn't support PHP 7 yet.

**EDIT: I have now found a way to get PHPMyAdmin updated to a compatible version without having to clone from GIT or compile manually from sources so I am adding this below:

First add this repository, update sources list and upgrade (NB: if it has been removed during the upgrade to PHP7 you will need to install rather than upgrade it):

sudo add-apt-repository ppa:nijel/phpmyadmin
sudo apt-get update
sudo apt-get dist-upgrade

However during installation (on my server) it had to run a database upgrade script upgrade_column_info_4_3_0+.sql but this failed with the following error:

mysql said: ERROR 1060 (42S21) at line 28: Duplicate column name 'input_transformation'

I chose to ignore the error and complete the upgrade. After installation I opened the .sql upgrade script at /usr/share/phpmyadmin/sql/upgrade_column_info_4_3_0+.sql

I ran the script manually removing the two offending lines trying to create 2 columns that already existed (code to remove):

ALTER TABLE `pma__column_info`
ADD `input_transformation` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
ADD `input_transformation_options` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';

Finally I had to edit the config file at /etc/phpmyadmin/ and add the following two lines:

$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';

After this PHPMyAdmin is successfully updated and the extended features are enabled. Hope this helps others.

At the time of this answer (February 2017), on Ubuntu 16.04 LTS, it is now possible to install php 7.0.* with the simple command:

apt-get install php

No need to add any third-party repositories.

I think the ppa has been added in 16.04 LTS.

  1. Just simply do sudo apt-get install php7.0 and that's it.
  2. Check if it installed by running php --version
  3. Also, you can create the info.php file in Apache's document root.
  4. That is in /var/www/html/ directory
  5. Run sudo gedit /var/www/html/info.php
  6. Add the following to the file: <?php phpinfo(); ?>. Note: the file is a blank file since you created it yourself.
  7. Now restart apache sudo service apache2 restart
  8. In your web browser, http://localhost/info.php that will give you full info about php.

Hope this helps :)

  • 1
    Don't I have to add it to Apache2? – Arlen Beiler Feb 13 '17 at 15:15
  • It's not a ppa, it's the official ubuntu build. – Jeff Puckett Aug 12 '17 at 14:21

I've collected a few different resources and resolved many issues to fully setup a build of PHP 7 on Ubuntu 15.04 and 15.10. Although it isn't a Debian package script, it does setup Ubuntu dependencies and configuration. The resources can be found over here.

You may need to select a release branch over just master and rerun the script.

I know that this may be a bad idea, but this is how I got php7 to work with my installation of Ubuntu Server 12.04.5 (i386):

sudo nano /etc/apt/sources.list

Then append the following at the end:

deb trusty main restricted universe multiverse
deb trusty partner

Then update as you normally would:

sudo apt-get update

Once you have PHP 7 installed on your apache server, you may have to move your files to a new directory to work:

sudo mv /var/www/* /var/www/html/

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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