How To Install PHP 8.0

PHP 8

PHP 8.0 has just been released! This new major version adds several significant features and improvements to the language like attributes, match expressions, Just-In-Time compilation (JIT), and much more!

Here's a brief guide on how to install PHP 8.0 on Linux, Windows, and Mac OS X:

Ubuntu

PHP 8.0 and commonly-used extensions can be installed by adding Ondřej Surý's PPA:

sudo apt install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

You can then install PHP 8.0 with all common extensions and SAPIs like so:

sudo apt install php8.0

Or you can specify individual packages like this instead:

sudo apt install php8.0-cli php8.0-fpm php8.0-bcmath php8.0-curl php8.0-gd php8.0-intl php8.0-mbstring php8.0-mysql php8.0-opcache php8.0-sqlite3 php8.0-xml php8.0-zip

This method is supported on:

  • Ubuntu 16.04 (Xenial)
  • Ubuntu 18.04 (Bionic)
  • Ubuntu 20.01 (Focal)
  • Ubuntu 20.10 (Groovy)

Debian

Ondřej Surý also provides PHP 8.0 packages for Debian. Add the repository with these commands:

sudo apt install -y apt-transport-https lsb-release ca-certificates wget
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 update

And then either install PHP 8.0 with all the defaults like this:

sudo apt install php8.0

Or list the exact packages you want instead:

sudo apt install php8.0-cli php8.0-fpm php8.0-bcmath php8.0-curl php8.0-gd php8.0-intl php8.0-mbstring php8.0-mysql php8.0-opcache php8.0-sqlite3 php8.0-xml php8.0-zip

This method is supported on:

  • Debian 9 (Stretch)
  • Debian 10 (Buster)

CentOS / RHEL & Fedora

Remi's RPM repository has RPMs for the latest PHP 8.0 builds.

RHEL/Centos 8 or Fedora modular:

dnf module reset php
dnf module install php:remi-8.0

RHEL/Centos 7 or Fedora:

yum-config-manager --enable remi-php80
yum update php\*

Or for parallel installation as a software collection, if you prefer to keep existing versions:

yum install php80

Refer to Remi's blog post for additional information on how to install this depending on which OS version you're running.

Mac OS X

Shivam Mathur has a Homebrew tap for easily installing PHP 8.0:

# Update homebrew
brew update

# Add the tap
brew tap shivammathur/php

# Install PHP 8.0
brew install shivammathur/php/[email protected]

Windows

Windows users can find the PHP 8.0 distributions on the windows.php.net website.

Docker

Official PHP images can be found on Docker Hub.

As of PHP 8.0's release date, the php:8.0 image hasn't been tagged yet; once it is, you can use that for your base images.

Docker is also a great way to tinker with PHP 8.0 in a local interactive shell without installing it first! Simply run this in your terminal:

docker run -it --rm php:8.0

Was this helpful?

About Colin O'Dell

Colin O'Dell

Colin O'Dell is the Director of Technology 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.