PHP 7.4 has just been released! This latest version adds several new features to the language such as arrow functions for shorter one-liner functions, typed properties in classes, covariant & contravariant type handling, Preloading for better performance, and much more!
Here's a brief guide on how to install PHP 7.4 on Linux, Windows, and Mac OS X:
Ubuntu
PHP 7.4 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 7.4 with all common extensions and SAPIs like so:
sudo apt install php7.4
Or you can specify individual packages like this instead:
sudo apt-get install php7.4-cli php7.4-fpm php7.4-bcmath php7.4-curl php7.4-gd php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-sqlite3 php7.4-xml php7.4-zip
This method is supported on:
- Ubuntu 16.04 (Xenial)
- Ubuntu 18.04 (Bionic)
- Ubuntu 19.04 (Disco)
- Ubuntu 19.10 (Eoan)
Debian
Ondřej Surý also provides PHP 7.4 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 7.4 with all the defaults like this:
sudo apt install php7.4
Or list the exact packages you want instead:
sudo apt install php7.4-cli php7.4-fpm php7.4-bcmath php7.4-curl php7.4-gd php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-sqlite3 php7.4-xml php7.4-zip
This method is supported on:
- Debian 8 (Jessie)
- Debian 9 (Stretch)
- Debian 10 (Buster)
CentOS / RHEL & Fedora
Remi's RPM repository has RPMs for the latest PHP 7.4 builds.
RHEL/Centos 8 or Fedora modular:
dnf module reset php
dnf module install php:remi-7.4
RHEL/Centos 7 or Fedora:
yum-config-manager --enable remi-php74
yum update php\*
Or for parallel installation as a software collection, if you prefer to keep existing versions:
yum install php74
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
Windows
Windows users can find the PHP 7.4 distributions on the windows.php.net website.
Additional instructions for installing the distribution can be found in this blog post: http://kizu514.com/blog/install-php7-and-composer-on-windows-10/
phpbrew
phpbrew is an amazing tool that helps you download, compile, and manage multiple versions of PHP on your machine. Assuming you've already followed the installation directions and have phpbrew
up-and-running, PHP 7.4.0 can be installed with two easy commands:
phpbrew update
phpbrew install -j $(nproc) 7.4 +default
Docker
Official PHP images can be found on Docker Hub.
As of PHP 7.4's release date, the php:7.4
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 7.4 in a local interactive shell without installing it first! Simply run this in your terminal:
docker run -it --rm php:7.4
Was This Helpful?
Support my open-source work via Github or follow me on Twitter for more blog posts and other interesting articles from around the web. I'd also love to hear your thoughts on this post - simply drop a comment below!