Installing PHP 7.2

PHP 7.2

PHP 7.2 has been released, bringing some great new features and security enhancements to the language such as object type hints, saner count() behavior, and much more.

Here's a brief guide on how to install PHP 7.2 on several different operating systems:

Ubuntu 14.04, 16.04, 17.04, & 17.10:

PHP 7.2 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.2-cli

View the full list of available packages here.

Debian 8 (Jessie) and 9 (Stretch)

Ondřej Surý also provides PHP 7.2 packages for Debian which can be installed using these commands:

sudo apt-get install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt-get update
sudo apt-get install php7.2-cli

Debian 7 (Wheezy)

PHP 7.2 can be compiled from source by following the instructions outlined here: Install PHP 7 on Debian Wheezy. Make sure you git checkout the appropriate tag after cloning the php-src repository.

CentOS / RHEL 6+ & Fedora 25+

Remi Collet, one of the release managers for PHP 7.2, also publishes RPM packages for this new version. You can use the configuration wizard to determine the exact setup steps, or see Remi's website for additional details about the 7.2.0 release.

Mac OS X

PHP 7.2 can easily be installed via Liip's php-osx tool:

curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2

Or, if you prefer using Homebrew:

brew tap homebrew/homebrew-php
brew install php72

Windows

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

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

phpbrew

phpbrew is a really nice tool that helps you download, compile, and manage multiple versions of PHP. Assuming you've already followed the installation directions and have phpbrew up-and-running, PHP 7.2.0 can be installed with two easy commands:

phpbrew update
phpbrew install -j $(nproc) 7.2.0 +default

Docker

Official PHP images can be found on Docker Hub. You can use the php:7.2 tag for base images.

If you'd like to tinker with PHP 7.2 in an interactive shell, simply run this in your terminal:

docker run -it --rm php:7.2
True

About Colin O'Dell

Colin O'Dell

Colin O'Dell is a Lead Web Developer at Unleashed Technologies, a web and hosting firm based in Maryland. 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.