Debian 13 (trixie) already ships PHP 8.4.x, Debian 12 (bookworm) ships PHP 8.2.x, and Debian 11 (bullseye) stays on PHP 7.4.x in the default APT sources. That matters when you want to install PHP 8.5 on Debian for Laravel, WordPress testing, or any project that needs the pipe operator, the URI extension, and the new array helper functions covered in the official PHP 8.5 release announcement.
Ondrej Sury’s Debian repository provides PHP 8.5 for all three releases and keeps branches co-installable, so PHP 8.4 and PHP 8.5 can share the same host during staged upgrades. PHP 8.5 remains in active support through December 2027 and receives security fixes through December 2029 according to the official PHP supported versions table.
Install PHP 8.5 on Debian
All supported Debian releases need the Sury repository for php8.5. If you prefer the distro branch instead, install the default PHP on Debian or install PHP 8.4 on Debian instead of adding a third-party source.
Refresh APT before adding the PHP 8.5 repository on Debian
Start with a fresh package index, then confirm which Debian codename the host is using before you add the Sury source.
sudo apt update
grep '^VERSION_CODENAME=' /etc/os-release
These commands use
sudofor package-management tasks that need root privileges. If your account does not have sudo access yet, follow the guide on how to add a user to sudoers on Debian.
VERSION_CODENAME=bookworm
The codename tells you which Sury suite to use next: trixie, bookworm, or bullseye.
Add the Sury PHP repository on Debian
The manual DEB822 method is the current Debian-safe path for Sury. It works on Debian 13, Debian 12, and Debian 11 without depending on an older extrepo setup.
If you used an older
extrepo-based Sury setup, remove/etc/apt/sources.list.d/extrepo_sury.sourcesand/var/lib/extrepo/keys/sury.ascbefore you continue. APT rejects duplicate Sury entries when theSigned-Bypaths do not match.
Install the prerequisite packages and download the Sury key into Debian’s system keyring path. Most server and minimal Debian installs need these packages even when a fuller desktop image already has them. The curl command in Linux guide breaks down the -fsSLo flags if you want to adapt the download pattern later.
sudo apt install -y ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
The sudo curl form writes the key directly into the root-owned keyring location, so you do not need a temporary file or a separate move step.
Load Debian’s release metadata in the current shell and keep using the same terminal for the next command.
. /etc/os-release
printf 'Using suite: %s\n' "$VERSION_CODENAME"
Using suite: bookworm
Create the DEB822 source file next. The printf | sudo tee pattern writes the file as root more reliably than a heredoc when readers copy it from WordPress into a terminal.
printf '%s\n' \
"Types: deb" \
"URIs: https://packages.sury.org/php/" \
"Suites: $VERSION_CODENAME" \
"Components: main" \
"Signed-By: /usr/share/keyrings/deb.sury.org-php.gpg" | sudo tee /etc/apt/sources.list.d/php.sources > /dev/null
Refresh APT again and confirm that php8.5 now comes from Sury.
sudo apt update
apt-cache policy php8.5
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://security.debian.org/debian-security bookworm-security InRelease
Hit:4 https://packages.sury.org/php bookworm InRelease
Reading package lists...
php8.5:
Installed: (none)
Candidate: 8.5.3-2+0~20260213.10+debian12~1.gbp7df0df
Version table:
8.5.3-2+0~20260213.10+debian12~1.gbp7df0df 500
500 https://packages.sury.org/php bookworm/main amd64 Packages
The suite and revision string change with your Debian release. On Debian 13, the same check shows
debian13withtrixie. On Debian 11, it showsdebian11withbullseye.
Compare PHP 8.5 web server setups on Debian
Choose the integration that matches the web stack you are actually running. If the server layer is not in place yet, start with Install Apache on Debian or Install Nginx on Debian first.
| Method | Packages | Best for | Trade-off |
|---|---|---|---|
| Apache with mod_php | apache2, libapache2-mod-php8.5 | Short-lived lab stacks and simple local development | Apache switches to the prefork MPM |
| Apache with PHP-FPM | apache2, php8.5-fpm, libapache2-mod-fcgid | Production Apache servers that need separate PHP worker pools | Requires Apache module and FPM configuration changes |
| Nginx with PHP-FPM | nginx, php8.5-fpm, php8.5-cli | Production Nginx deployments and LEMP stacks | Nginx needs a FastCGI block that points at the right socket |
- Use Apache with mod_php when you want the shortest path to a working local PHP stack.
- Use Apache with PHP-FPM when you want Apache in front but still need cleaner process separation.
- Use Nginx with PHP-FPM when the host already runs Nginx or you plan to build a LEMP stack for Install WordPress with Nginx on Debian.
Install PHP 8.5 with Apache mod_php on Debian
This path suits smaller Apache deployments where simplicity matters more than process isolation.
sudo apt install -y apache2 libapache2-mod-php8.5
sudo systemctl restart apache2
Installing libapache2-mod-php8.5 enables the PHP module automatically. Debian commonly keeps /usr/sbin outside an unprivileged shell’s default PATH, so the full apache2ctl path makes the verification command more reliable.
sudo /usr/sbin/apache2ctl -M 2>/dev/null | grep php
php_module (shared)
Install PHP 8.5 with Apache and PHP-FPM on Debian
This setup keeps Apache in front while handing PHP requests to a separate FPM service.
sudo apt install -y apache2 php8.5-fpm libapache2-mod-fcgid
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.5-fpm
sudo systemctl enable php8.5-fpm --now
sudo systemctl restart apache2
If you previously tested
libapache2-mod-php8.5on the same host, disable it before you enable the FPM configuration withsudo a2dismod php8.5.
The php8.5-fpm package provides the php-fpm8.5 service and the /run/php/php8.5-fpm.sock socket used by both Apache and Nginx.
systemctl is-active php8.5-fpm
ls -l /run/php/php8.5-fpm.sock
sudo /usr/sbin/apache2ctl -M 2>/dev/null | grep proxy_fcgi
sudo /usr/sbin/a2query -c php8.5-fpm
active srw-rw---- 1 www-data www-data 0 Mar 14 09:24 /run/php/php8.5-fpm.sock proxy_fcgi_module (shared) php8.5-fpm (enabled by site administrator)
Install PHP 8.5 with Nginx and PHP-FPM on Debian
Nginx always uses PHP-FPM for PHP requests, so this path installs the FPM service and the CLI tools together.
sudo apt install -y nginx php8.5-fpm php8.5-cli
sudo systemctl enable php8.5-fpm --now
Add this location block to the relevant server block so Nginx passes PHP requests to the PHP 8.5 socket.
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.5-fpm.sock;
}
Check the service state, confirm that the socket exists, then test the Nginx configuration before you reload it.
systemctl is-active php8.5-fpm
ls -l /run/php/php8.5-fpm.sock
sudo nginx -t
active srw-rw---- 1 www-data www-data 0 Mar 14 09:24 /run/php/php8.5-fpm.sock nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Once the syntax check passes, reload Nginx to pick up the change.
sudo systemctl reload nginx
Verify the PHP 8.5 CLI on Debian
Confirm the interpreter version before you move on to extensions or application setup.
php --version
PHP 8.5.3 (cli) (built: Feb 13 2026 15:52:21) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.5.3, Copyright (c) Zend Technologies
with Zend OPcache v8.5.3, Copyright (c), by Zend Technologies
Install PHP 8.5 extensions on Debian
Most PHP applications need extra modules beyond the base interpreter. This extension set covers the usual requirements for WordPress, Laravel, API clients, database access, image handling, caching, and debugging.
Install common PHP 8.5 extensions on Debian
Install the modules that match the application you are building. php8.5-mysql provides both mysqli and pdo_mysql, while php8.5-xml bundles DOM, XMLReader, and XMLWriter support.
sudo apt install -y php8.5-curl php8.5-mysql php8.5-gd php8.5-zip php8.5-intl php8.5-bcmath php8.5-imagick php8.5-xmlrpc php8.5-readline php8.5-memcached php8.5-redis php8.5-mbstring php8.5-apcu php8.5-xml php8.5-xdebug php8.5-soap
There is no separate
php8.5-opcachepackage in Sury. Zend OPcache ships withphp8.5-common, which the base PHP packages already install. JSON support is also built into PHP 8.x, so you do not need aphp8.5-jsonpackage either.
Restart the PHP handler after you add extensions so the web server loads the new modules.
sudo systemctl restart php8.5-fpm
If the host uses Apache with mod_php instead of PHP-FPM, restart Apache with
sudo systemctl restart apache2instead.
Verify a few commonly needed modules, then confirm that Zend OPcache is active in the CLI build.
php8.5 -m | grep -E 'curl|gd|mbstring|mysqli|xml$'
php --version | grep 'Zend OPcache'
curl
gd
mbstring
mysqli
xml
with Zend OPcache v8.5.3, Copyright (c), by Zend Technologies
For a fuller application stack, pair PHP 8.5 with Install WordPress with Apache on Debian or Install WordPress with Nginx on Debian after the required modules are in place.
Search available PHP 8.5 extensions on Debian
Use the package cache when you need a module that is not in the common list.
apt-cache search '^php8.5-' | sed -n '1,12p'
libapache2-mod-php8.5 - server-side, HTML-embedded scripting language (Apache 2 module) libphp8.5-embed - HTML-embedded scripting language (Embedded SAPI library) php8.5-amqp - AMQP extension for PHP php8.5-apcu - APC User Cache for PHP php8.5-ast - AST extension for PHP 7 php8.5-bcmath - Bcmath module for PHP php8.5-bz2 - bzip2 module for PHP php8.5-calendar - calendar module for PHP php8.5-curl - CURL module for PHP php8.5-dba - DBA module for PHP php8.5-decimal - arbitrary precision decimal arithmetic for PHP php8.5-dev - Files for PHP8.5 module development
Run multiple PHP versions on Debian
Sury packages each PHP branch independently, so PHP 8.4 and PHP 8.5 can stay installed together on the same host. That is useful when you need one branch for a production application and another for testing or upgrade work.
Check the PHP CLI default with update-alternatives on Debian
Use Debian’s alternatives system to see which PHP binary the plain php command will launch.
sudo update-alternatives --query php
Name: php Link: /usr/bin/php Slaves: php.1.gz /usr/share/man/man1/php.1.gz Status: auto Best: /usr/bin/php8.5 Value: /usr/bin/php8.5 Alternative: /usr/bin/php8.4 Priority: 84 Alternative: /usr/bin/php8.5 Priority: 85
Set PHP 8.5 explicitly if another branch is still the active CLI default.
sudo update-alternatives --set php /usr/bin/php8.5
Switch Apache from PHP 8.4 to PHP 8.5 on Debian
For mod_php, disable the old module first, then enable the new branch and restart Apache.
sudo a2dismod php8.4
sudo a2enmod php8.5
sudo systemctl restart apache2
sudo /usr/sbin/apache2ctl -M 2>/dev/null | grep php
php_module (shared)
Switch Apache PHP-FPM from PHP 8.4 to PHP 8.5 on Debian
Apache with PHP-FPM switches branches by changing the enabled FPM configuration file instead of loading a PHP module.
sudo a2disconf php8.4-fpm
sudo a2enconf php8.5-fpm
sudo systemctl restart apache2
sudo /usr/sbin/a2query -c php8.5-fpm
php8.5-fpm (enabled by site administrator)
Switch Nginx from PHP 8.4 to PHP 8.5 on Debian
Nginx only needs the FastCGI socket path updated, followed by a syntax test and reload.
# Old branch
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
# New branch
fastcgi_pass unix:/run/php/php8.5-fpm.sock;
sudo nginx -t
sudo systemctl reload nginx
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Remove PHP 8.5 from Debian
Remove PHP 8.5 packages on Debian
Quote the package glob so your shell passes it to APT unchanged, then remove the PHP 8.5 packages you no longer need.
sudo apt remove 'php8.5*'
sudo apt purge 'php8.5*'
sudo apt autoremove -y
Check for any remaining installed PHP 8.5 packages after the purge finishes.
dpkg -l | grep php8.5
No output means the installed PHP 8.5 packages are gone.
Remove the Sury repository from Debian
Delete the manual source file and keyring when you no longer want packages from Sury.
sudo rm -f /etc/apt/sources.list.d/php.sources /usr/share/keyrings/deb.sury.org-php.gpg
sudo apt update
apt-cache policy php | sed -n '1,6p'
php:
Installed: (none)
Candidate: 2:8.4+96
Version table:
2:8.4+96 500
500 http://deb.debian.org/debian trixie/main amd64 Packages
On Debian 12, the same check falls back to
2:8.2+93. On Debian 11, it falls back to2:7.4+76from the default Debian sources.
Troubleshoot PHP 8.5 on Debian
Resolve a Signed-By conflict from an older extrepo setup
If you previously enabled Sury with extrepo and then add the manual php.sources file from this article, APT stops because both source files point to the same repository with different key paths.
Error: Conflicting values set for option Signed-By regarding source https://packages.sury.org/php/ trixie: /var/lib/extrepo/keys/sury.asc != /usr/share/keyrings/deb.sury.org-php.gpg Error: The list of sources could not be read.
Remove the old extrepo source and key, then refresh APT before you continue with the manual Sury configuration.
sudo rm -f /etc/apt/sources.list.d/extrepo_sury.sources /var/lib/extrepo/keys/sury.asc
sudo apt update
Hit:1 http://security.debian.org/debian-security trixie-security InRelease Hit:2 http://deb.debian.org/debian trixie InRelease Hit:3 http://deb.debian.org/debian trixie-updates InRelease Hit:4 https://packages.sury.org/php trixie InRelease Reading package lists...
Fix the php8.5-fpm socket not found error on Debian
Nginx returns a 502 error when the PHP-FPM service is stopped or when the FastCGI socket path does not match the running branch.
ls -l /run/php/php8.5-fpm.sock
systemctl is-active php8.5-fpm
srw-rw---- 1 www-data www-data 0 Mar 14 09:24 /run/php/php8.5-fpm.sock active
If the socket is missing or the service is inactive, start PHP-FPM again and retest Nginx.
sudo systemctl enable php8.5-fpm --now
sudo nginx -t
sudo systemctl reload nginx
Fix the unable to locate package php8.5-opcache error on Debian
This error usually appears because readers expect OPcache to be split into its own package. Sury does not publish a separate php8.5-opcache package, so APT cannot find it.
Reading package lists... Building dependency tree... Reading state information... E: Unable to locate package php8.5-opcache E: Couldn't find any package by glob 'php8.5-opcache' E: Couldn't find any package by regex 'php8.5-opcache'
Check the base package candidates instead. If php8.5 and php8.5-common appear, OPcache comes with the normal PHP install.
apt-cache policy php8.5 php8.5-common | sed -n '1,12p'
php8.5:
Installed: (none)
Candidate: 8.5.3-2+0~20260213.10+debian12~1.gbp7df0df
Version table:
8.5.3-2+0~20260213.10+debian12~1.gbp7df0df 500
500 https://packages.sury.org/php bookworm/main amd64 Packages
php8.5-common:
Installed: (none)
Candidate: 8.5.3-2+0~20260213.10+debian12~1.gbp7df0df
Install php8.5 or php8.5-common, not php8.5-opcache. If even php8.5 is missing, go back to the Sury repository section and rerun sudo apt update.
PHP 8.5 on Debian FAQ
No. Debian 13 (trixie) ships PHP 8.4.x in its default APT sources. Debian 12 (bookworm) ships PHP 8.2.x, and Debian 11 (bullseye) ships PHP 7.4.x, so all three releases need the Sury repository for PHP 8.5.
Sury does not publish a separate php8.5-opcache package. Zend OPcache ships with php8.5-common, which is installed with the normal PHP 8.5 packages.
Yes. Sury packages each PHP branch independently, so Debian can keep PHP 8.4 and PHP 8.5 installed together. Use update-alternatives for the CLI default and separate FPM sockets or Apache configs for the web stack.
Use php8.5-fpm for production deployments on Apache or Nginx because it keeps PHP in separate worker pools. Use mod_php when you want the simplest Apache-only setup for a lab host or local development.
Conclusion
PHP 8.5 on Debian fits cleanly into Apache or Nginx once the Sury repository and the right extension set are in place. From here, Install PHP Composer on Debian for dependency management, then lock down the web tier with Secure Apache with Let’s Encrypt on Debian or Secure Nginx with Let’s Encrypt on Debian before the site goes live.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>