Installing PHP 7.0

Installing PHP 7.0 is easier than ever.  Here are instructions for installing the latest version on different platforms:

PHP 5.x Conflicts

You may encounter conflicts if you already have PHP 5.x installed. If so, make sure to completely remove PHP 5.x from your system before installing 7.0. On Ubuntu, this is as simple as running: sudo apt-get purge php5-*.

Ubuntu 14.04, 15.04, 15.10, and 16.04:

PHP 7.0 can be installed using Ondřej Surý's PPA:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0

View full list of available packages

Debian 8 (Jessie)

PHP 7.0 can be installed using the Dotdeb repository.

Add these two lines to your /etc/apt/sources.list file:

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

Add the GPG key:

wget https://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg

Install PHP 7:

sudo apt-get update
sudo apt-get install php7.0

View full list of available packages

Debian 7 (Wheezy)

PHP 7 can be compiled from source by following the instructions outlined here: Install PHP 7 on Debian Wheezy

CentOS / RHEL

PHP 7.0 can be installed using the Webstatic Yum repository.

If you're using CentOS/RHEL 7.x, run these three commands to add the repository and install PHP 7:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w

If you're using CentOS/RHEL 6.x, run these two commands to add the repository and install PHP 7:

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
yum install php70w

View full list of available packages

Mac OS X 10.6 - 10.11

PHP 7.0 can be installed using homebrew:

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php70

Or you can install it via Liip's php-osx tool:

curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0

Windows

PHP 7.0 distributions for Windows can be found on the windows.php.net website: http://windows.php.net/download#php-7.0

You can find instructions for installing the distribution here: https://www.webtechgadgetry.com/install-php-7-windows/

Enjoy this article?

About Colin O'Dell

Colin O'Dell

Colin O'Dell is a Lead Software Engineer at SeatGeek. In addition to being an active member of the PHP League and maintainer of the league/commonmark project, Colin is also a PHP docs contributor, conference speaker, and author of the PHP 7 Migration Guide.