Installing PHP 7.2

PHP 7.2

Psst - PHP 7.4 is now available! Learn how to upgrade to PHP 7.4 here!

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, & 18.04

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
echo "deb $(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 | bash -s 7.2

Or, if you prefer using Homebrew:

brew tap homebrew/homebrew-php
brew install php72


PHP 7.2 distributions for Windows can be found on the website:

You can find instructions for installing the distribution here:


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


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

Was this helpful?

About Colin O'Dell

Colin O'Dell

Colin O'Dell is a Senior 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.