Step‑by‑Step Guide to Installing and Configuring PHP 8.5 on Ubuntu/Debian
This guide walks you through installing PHP 8.5 on Ubuntu or Debian, covering repository setup, package installation, extension management, PHP‑FPM configuration, web‑server integration, configuration migration, and removal of older PHP versions, with concrete commands and safety tips.
Overview
PHP 8.5 introduces pipe syntax, a new URI extension, many deprecations and performance improvements, and is now officially released. The guide explains how to install it on Ubuntu/Debian or upgrade from earlier PHP versions.
Backward‑Compatibility Breaks
PHP 8.5 is largely compatible with PHP 8.4, but introduces several deprecations to enforce recommended APIs. No bundled extensions are removed, and no functions, constants, or classes supported in PHP 8.4+ are dropped.
Opcache is now always bundled (cannot be installed separately).
Two new core extensions, uri and lexbor, are always included.
A new max_memory_limit INI directive (disabled by default) caps memory_limit.
The -z CLI option has been removed.
The disable_classes INI directive has been removed.
Before proceeding, back up your system. The steps below are non‑destructive unless otherwise noted.
PHP 8.5 receives four years of security updates, with bug fixes for the first two years.
1. Record Existing PHP Packages
When upgrading, save the list of currently installed extensions to reinstall the same set on PHP 8.5.
Save php -m output
php -m | tee php-m-output.txtSave dpkg -l output filtered for PHP packages
dpkg -l | grep php | tee dpkg-l-output.txt2. Add Ondřej’s PHP PPA/DPA
Ubuntu 24.10 does not ship PHP 8.5. Add Ondřej Surý’s repository, which provides PHP 8.5 and several PECL extensions.
Ubuntu
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
# Press Enter to confirm.
sudo apt updateDebian
sudo apt-get update
sudo apt-get -y install lsb-release ca-certificates curl apt-transport-https
# Download and add the signing key
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 update3. Install New PHP 8.5 Packages
After adding the repository, install the PHP 8.5 packages. All packages are prefixed with php8.5- and can coexist with other PHP versions.
Install PHP CLI
sudo apt install php8.5-cliVerify the installation with php -v.
php -vInstall Common Extensions
sudo apt install php8.5-common php8.5-{bcmath,bz2,curl,gd,gmp,intl,mbstring,openssl,readline,xml,zip}Check installed extensions with php -m.
Install PHP‑FPM
sudo apt install php8.5-fpmVerify the service is running:
sudo systemctl status php8.5-fpmWeb‑Server Integration
Apache : enable the PHP 8.5 config. sudo a2enconf php8.5-fpm Nginx : update fastcgi_pass to the new socket. <code>fastcgi_pass unix:/run/php/php8.4-fpm.sock;
fastcgi_pass unix:/run/php/php8.5-fpm.sock;</code> Caddy : change reverse_proxy to the new socket. <code>reverse_proxy @phpFiles unix//run/php/php8.4-fpm.sock
reverse_proxy @phpFiles unix//run/php/php8.5-fpm.sock</code> Additional PHP Extensions Other extensions follow the same php8.5- naming scheme. Development tools such as Xdebug and PCOV can be installed similarly, but they are not recommended on production servers. Xdebug <code>sudo apt install php8.5-xdebug</code> PCOV <code>sudo apt install php8.5-pcov</code> Configuration Migration New configuration files appear under /etc/php/8.5 . Existing installations reside in /etc/php/VERSION . Compare php.ini files and merge differences rather than overwriting. <code>diff /etc/php/8.4/cli/php.ini /etc/php/8.5/cli/php.ini</code> When using PHP‑FPM, update /etc/php/8.5/fpm/pool.d/www.conf accordingly. Enable or disable extensions with phpenmod and phpdismod . <code>phpdismod -v 8.5 zip
phpenmod -v 8.5 zip</code> Remove Old PHP Versions After confirming the new setup works, purge obsolete packages, e.g., all PHP 8.4 packages: <code>sudo apt purge '^php8.4.*'</code> Running Multiple PHP Versions PHP 8.5 binaries install to /usr/bin/php8.5 ; other versions install similarly (e.g., /usr/bin/php8.4 ). The generic php command points to the highest version by default, but you can change it with update-alternatives : <code>sudo update-alternatives --config php</code> Or set it directly: <code>update-alternatives --set php /usr/bin/php8.5</code> Quick Summary 1. Add PHP 8.5 source Ubuntu: <code>sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt update</code> Debian: <code>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</code> 2. Install PHP 8.5 packages <code>sudo apt install php8.5-cli
sudo apt install php8.5-common php8.5-{bcmath,bz2,curl,gd,gmp,intl,mbstring,openssl,readline,xml,zip}</code>
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
