Ubuntu: How to install PHP 7? (9 Solutions!!)
Channel: Roel Van de Paar
Date: 30/06/2019

Ubuntu: How to install PHP 7?


Question: PHP 7 came out http://php.net/archive/2015.php#id2015-12-03-1 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
     http://php.net/archive/2015.php#id2015-12-03-1
----
Is that possible to install it on current Ubuntu version?
Is there any current limitations or known compatibility issues?

Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):

== This solution helped 10 people ==
For Ubuntu 16.04, PHP7 is now the default official upstream version.
sudo apt install php
Here's https://www.atlantic.net/community/howto/install-linux-apache-mysql-php-
lamp-stack-on-ubuntu-16-04/.

== This solution helped 175 people ==
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 https://
gist.github.com/jaswsinc/d4fc3d3808001c7836fa or following instruction on this
blog.
EDIT:
PHP5 has now been https://www.symfony.fi/entry/php-7-included-in-ubuntu-16-04-
lts-xenial-xeruswith PHP7 as the default PHP in Ubuntu 16.4 so, to install PHP7
on Ubuntu 16.04:
sudo apt-get install php7.0
Or
sudo apt-get install php

== This solution helped 17 people ==
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 https://files.phpmyadmin.net/phpMyAdmin/4.5.3.1/phpMyAdmin-4.5.3.1-
all-languages.zip
sudo unzip phpMyAdmin-4.5.3.1-all-languages.zip
sudo mv phpMyAdmin-4.5.3.1-all-languages/ phpmyadmin/
sudo mkdir -m 777 phpmyadmin/config/
sudo /etc/init.d/apache2 restart

With thanks & praise to God! With thanks to all the many who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music & music license: https://www.bensound.com/royalty-free-music | Images & images license: https://stocksnap.io/license and others | With thanks to user Tshilidzi Mudau (https://askubuntu.com/users/476968), user thomasrutter (https://askubuntu.com/users/54256), user Robin Wilson (https://askubuntu.com/users/252594), user m1st0 (https://askubuntu.com/users/215535), user Leo Galleguillos (https://askubuntu.com/users/287773), user KimChoJapFan (https://askubuntu.com/users/644069), user Jeff Puckett (https://askubuntu.com/users/453746), user Jeff Puckett (https://askubuntu.com/users/453746), user Jarek Jakubowski (https://askubuntu.com/users/441521), user hg8 (https://askubuntu.com/users/338915), user HerrWalter (https://askubuntu.com/users/582637), user David Foerster (https://askubuntu.com/users/175814), user Collin (https://askubuntu.com/users/479589), and the Stack Exchange Network (http://askubuntu.com/questions/705880). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything should be amiss at Roel D.OT VandePaar A.T gmail.com.