Step‑by‑Step Guide to Install or Upgrade PHP 8.4 on Ubuntu/Debian

This guide explains how to add Ondřej Surý's repository, install PHP 8.4 alongside existing versions, handle deprecated features, configure web‑server integration, manage extensions, verify the installation, and safely remove older PHP packages on Ubuntu or Debian systems.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
Step‑by‑Step Guide to Install or Upgrade PHP 8.4 on Ubuntu/Debian

Overview

This guide shows how to install or upgrade to PHP 8.4 on Ubuntu, Debian, or derivatives. Because PHP 8.4 is not available in the default distribution repositories, the guide uses the third‑party repository maintained by Ondřej Surý, which provides up‑to‑date binaries and PECL extensions.

Potential Backward‑Compatibility Changes

PHP 8.4 introduces new features (property hooks, asymmetric visibility, DOM, Curl, PCRE improvements) but also deprecates and removes several items that may affect existing applications:

Deprecated implicit nullable parameter declarations.

Deprecated E_STRICT constant.

Four extensions moved from the core to PECL: Pspell, IMAP, OCI8, and PDO_OCI.

Extensions that have moved to PECL follow their own release cycles and may lag behind core updates.

List Existing PHP Packages (Upgrade Scenario)

When upgrading an existing PHP installation, list all installed packages containing the string php and save the list to packages.txt for later reference.

dpkg -l | grep php | tee packages.txt

Add Ondřej Surý’s PPA/DPA

Because PHP 8.4 is unavailable in the official repos, add the external repository.

Ubuntu PPA

sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php # Press enter to confirm.
sudo apt update

Debian DPA

sudo apt-get update
sudo apt-get -y install lsb-release ca-certificates curl apt-transport-https
sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt-get update

Install PHP 8.4 Server API Packages

Packages follow the php8.4‑NAME naming scheme. Choose the appropriate SAPI:

CLI Only

sudo apt install php8.4-cli

CLI + Apache Module

sudo apt install php8.4-cli libapache2-mod-php8.4

CLI + PHP‑FPM (Recommended)

sudo apt install php8.4-cli php8.4-fpm

This installs the php8.4-fpm service and enables it automatically.

Verify Installation

Check the PHP version: php -v For PHP‑FPM status:

sudo systemctl status php8.4-fpm

Install PHP Extensions

All shared and PECL extensions use the php8.4‑EXTNAME pattern. Install a specific extension, e.g., GD: sudo apt install php8.4-gd Install a common set of extensions:

sudo apt install php8.4-common php8.4-{bcmath,bz2,curl,gd,gmp,intl,mbstring,opcache,readline,xml,zip}

Search for additional extensions:

apt search php8.4

Web Server Integration

Configuration may be required depending on the chosen SAPI.

PHP‑FPM

Apache : enable the PHP 8.4 FPM config: sudo a2enconf php8.4-fpm Nginx : update fastcgi_pass to the new socket:

- fastcgi_pass unix:/run/php/php8.3-fpm.sock;
+ fastcgi_pass unix:/run/php/php8.4-fpm.sock;

Caddy : modify reverse_proxy to use the new socket:

- reverse_proxy @phpFiles unix//run/php/php8.3-fpm.sock
+ reverse_proxy @phpFiles unix//run/php/php8.4-fpm.sock

Migrate Configuration Files

New configuration resides in /etc/php/8.4; older versions use /etc/php/VERSION. Compare and merge php.ini files, and for FPM update /etc/php/8.4/fpm/pool.d/www.conf as needed.

diff /etc/php/8.3/cli/php.ini /etc/php/8.4/cli/php.ini

Remove Old PHP Versions

After confirming the new installation works, purge obsolete packages, e.g., all PHP 8.3 packages:

sudo apt purge '^php8.3.*'

Running Multiple PHP Versions Side‑by‑Side

CLI binaries are installed with versioned names ( /usr/bin/php8.4, /usr/bin/php8.3). The generic php command points to the default version, which can be changed with update-alternatives: sudo update-alternatives --config php To set PHP 8.4 as the default without interaction:

update-alternatives --set php /usr/bin/php8.4
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendPHPInstallationServerUbuntuDebian
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.