PHP 8.5 is the newest major release of the PHP language, published by the PHP development team in November 2025. It builds on the performance work of the 8.x series and adds some genuinely useful additions to the language, such as the pipe operator, the #[\NoDiscard] attribute, array_first() and array_last(), persistent cURL handles, and fatal error backtraces that finally tell you where a crash actually came from.
This guide will show you how to install PHP 8.5 on Ubuntu 26.04 LTS (Resolute Raccoon). We will use the well-known ondrej/php PPA, which packages every supported PHP branch for Ubuntu and is updated within days of each upstream release. You will install the CLI binary, add the extensions most applications need, wire PHP up to either Apache or Nginx, and learn how to keep several PHP versions side by side on the same server.
Before you start, make sure you have an Ubuntu 26.04 machine with a user that has sudo privileges and a working internet connection. The whole process takes about ten minutes.
Step 1: Update Your System
Before installing anything, it’s good practice to refresh the package index and apply pending updates. Open your terminal and run the following commands:
sudo apt updatesudo apt upgrade
If the upgrade installs a new kernel, reboot the server before moving ahead. You will also need a couple of small helper packages to add a third-party repository:
sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https -y
Step 2: Add the PHP PPA
Ubuntu 26.04 ships a PHP version in its own repositories, but that version is frozen for the life of the release and only receives backported security fixes. Adding Ondřej Surý’s PPA gives you PHP 8.5 packages built specifically for Ubuntu 26.04, along with every extension you are likely to need and regular point-release updates.
sudo add-apt-repository ppa:ondrej/php
Press Enter when the prompt asks you to confirm. The command adds the repository definition and imports its signing key, then refreshes the package lists for you. If you skipped the automatic refresh, run it manually:
sudo apt update
Adding this PPA does not change any PHP version already installed on the system. It only makes the newer packages available to apt.
Step 3: Install PHP 8.5
Now install the PHP 8.5 command line interpreter and its common libraries:
sudo apt install php8.5 php8.5-cli php8.5-common -y
Check the installed version to confirm everything went well:
php -v
The output should look similar to this:
PHP 8.5.0 (cli) (built: Nov 20 2025 11:42:07) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.0, Copyright (c) Zend Technologies
with Zend OPcache v8.5.0, Copyright (c), by Zend Technologies
Step 4: Install PHP Extensions
The base package is deliberately minimal. Most real applications need a handful of extensions on top of it. This set covers what WordPress, Laravel, Symfony, and similar projects expect:
sudo apt install php8.5-{mysql,pgsql,curl,gd,mbstring,xml,zip,intl,bcmath,soap,opcache,readline} -y
List the enabled modules to verify them:
php -m
A few notes on choosing extensions:
- php8.5-mysql and php8.5-pgsql are the database drivers. Install only the one your database actually uses.
- php8.5-opcache caches compiled bytecode and is the single biggest performance win on a production server. Always install it.
- php8.5-mbstring, php8.5-xml, and php8.5-curl are required by almost every framework and CMS.
- If a package is missing, search for it with apt search php8.5- rather than guessing the name.
Step 5: Configure PHP 8.5 with Apache
Skip this step if you use Nginx. To run PHP under the Apache web server, install the Apache PHP module:
sudo apt install apache2 libapache2-mod-php8.5 -y
If an older PHP module was already active, disable it and switch to 8.5:
sudo a2dismod php8.4sudo a2enmod php8.5sudo systemctl restart apache2
The a2dismod command fails harmlessly if no other PHP module was enabled, so you can run it either way.
Step 6: Configure PHP 8.5 with Nginx (PHP-FPM)
Nginx has no built-in PHP module, so it hands PHP requests to the FastCGI Process Manager. Install PHP-FPM:
sudo apt install nginx php8.5-fpm -y
Start the service and enable it at boot:
sudo systemctl enable --now php8.5-fpmsudo systemctl status php8.5-fpm
Then point an Nginx server block at the PHP-FPM socket. Edit your site configuration, for example /etc/nginx/sites-available/default, and add the PHP location block:
server {
listen 80;
server_name example.com;
root /var/www/html;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.5-fpm.sock;
}
}
Test the configuration for syntax errors, then reload Nginx:
sudo nginx -tsudo systemctl reload nginx
Note the socket path. It contains the PHP version number, so it changes to php8.5-fpm.sock after an upgrade. Forgetting to update it is the most common cause of a 502 Bad Gateway error after moving to a new PHP release.
Step 7: Adjust PHP Settings
Each SAPI (server API) has its own configuration file. The CLI reads /etc/php/8.5/cli/php.ini, Apache reads /etc/php/8.5/apache2/php.ini, and PHP-FPM reads /etc/php/8.5/fpm/php.ini. Editing the wrong one is a classic time waster, so confirm which file is loaded first:
php --ini
Open the file for the SAPI your site uses:
sudo nano /etc/php/8.5/fpm/php.ini
These are sensible starting values for a typical web application:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 120
date.timezone = UTC
Save the file and exit the text editor (Ctrl + X, then Y, then Enter). Configuration changes are only picked up after the service restarts:
sudo systemctl restart php8.5-fpm
For Apache with mod_php, restart Apache instead with sudo systemctl restart apache2. CLI scripts read the file on every run, so no restart is needed there.
Step 8: Test Your PHP Installation
Create a small test file in your web root:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Now open http://your-server-ip/info.php in a browser. You should see the PHP information page with PHP Version 8.5.0 at the top, along with the list of loaded extensions and the active configuration file.
Once you have confirmed everything works, delete the file. It exposes details about your server that are useful to an attacker:
sudo rm /var/www/html/info.php
Step 9: Switch Between Multiple PHP Versions
The PPA lets you keep several PHP versions installed at the same time, which is handy when one application is not ready for 8.5 yet. List the available CLI binaries:
sudo update-alternatives --config php
Pick the number matching the version you want as the default php command, or set it directly without the interactive prompt:
sudo update-alternatives --set php /usr/bin/php8.5
Keep in mind that this only changes the command line binary. The version your website uses is decided by the Apache module you enabled in Step 5, or by the FPM socket in your Nginx configuration from Step 6. With Nginx you can even run different versions per site by pointing each server block at a different fastcgi_pass socket.
Conclusion
Installing PHP 8.5 on Ubuntu 26.04 LTS is straightforward once the PPA is in place. You added the repository, installed the interpreter and the extensions your application needs, connected PHP to Apache or Nginx, tuned a few settings in php.ini, and verified the result in a browser. Because the packages come from an apt repository, future 8.5 point releases arrive with a normal system upgrade. Before moving a production site to 8.5, run your test suite and check the upstream migration notes for deprecations that affect your code. Happy coding!
Frequently Asked Questions (FAQs)
Which PHP version does Ubuntu 26.04 ship by default?
Ubuntu 26.04 LTS includes a PHP version in its own repositories, and that version stays frozen for the life of the release apart from backported security fixes. Run apt policy php to see exactly which version your system offers. If it already matches what your application needs, you can install it with plain sudo apt install php and skip the PPA entirely. Use the PPA when you specifically want PHP 8.5, want point-release updates as they land, or need to run more than one PHP version on the same server.
Is the ondrej/php PPA safe to use in production?
It is the most widely used third-party PHP repository for Debian and Ubuntu, maintained by Ondřej Surý, who also maintains the official PHP packages in Debian. Many production servers run on it. That said, it is still a personal package archive rather than an Ubuntu-supported repository, so its packages do not come with Canonical’s security guarantee. Test upgrades on a staging server first, and pin the version if you need to control exactly when PHP moves forward.
What is the difference between mod_php and PHP-FPM?
mod_php embeds the PHP interpreter inside every Apache worker process. It is simple to set up but uses more memory and only works with Apache’s prefork MPM. PHP-FPM runs PHP as a separate pool of processes that the web server talks to over a socket. It works with both Apache and Nginx, uses less memory under load, lets you run different PHP versions per site, and is the recommended choice for anything beyond a small personal server.
Will upgrading to PHP 8.5 break my existing website?
Possibly, and you should test before switching. PHP 8.5 removes some previously deprecated behaviour and adds new deprecations of its own. Applications that were already running cleanly on PHP 8.4 usually need little or no work, but older code, abandoned plugins, and unmaintained libraries are the usual sources of trouble. Install 8.5 alongside your current version, run your test suite with php8.5 vendor/bin/phpunit, and check the error log with error_reporting set to E_ALL before you switch the web server over.
How do I install extensions that are not in the list above?
Search the repository for the exact package name, then install it. For example:
apt search php8.5- | grep redissudo apt install php8.5-redis -y
Restart PHP-FPM or Apache afterwards so the new module is loaded, and confirm it with php -m. Extensions that have no distribution package can still be built with pecl after installing php8.5-dev.
Why does my site still show the old PHP version after installing 8.5?
Almost always because the web server was not switched over. The php -v command reports the CLI binary, which is separate from what your site runs. With Apache, make sure php8.5 is the enabled module and the older one is disabled. With Nginx, check that fastcgi_pass points at /run/php/php8.5-fpm.sock. Restart the web server after either change, then load a phpinfo() page to confirm.
How do I remove PHP 8.5 or roll back to an earlier version?
Install the version you want to return to, switch the web server and update-alternatives back to it, then purge 8.5:
sudo apt purge 'php8.5*' -ysudo apt autoremove -y
Your configuration files under /etc/php/8.5 are removed by the purge, so back up anything you customised first. The PPA itself can stay in place, since it does not force any upgrades on its own.
Do I need to reinstall Composer after upgrading PHP?
No. Composer is a PHP script and simply runs under whichever PHP binary is the default. After switching versions, run composer -V to confirm it starts cleanly, then run composer update in your project so dependency constraints are re-evaluated against the new PHP version. If a package declares it does not support PHP 8.5 yet, Composer will tell you during that step.