Skip to content

How to Install PHP on Ubuntu 26.04 (PHP 8.5)

Install PHP 8.5 on Ubuntu 26.04 LTS from Ubuntu's repositories, add extensions, set up Apache or Nginx, and run PHP 8.4 or older while the PPA lacks 26.04.

Steps
7
Category
PHP
Covers
Ubuntu
Versions & support
About PHP →, About Ubuntu →
On this page 7 steps

PHP still runs a large share of the web. WordPress, Laravel, Drupal, Nextcloud and countless in-house applications depend on it, so installing PHP is usually one of the first jobs on a new Ubuntu 26.04 LTS (Resolute Raccoon) server.

Ubuntu 26.04 ships PHP 8.5 in its own repositories, and Canonical maintains it with security fixes for the whole life of the release. This guide shows how to install it, add the extensions most applications need, connect PHP to Apache or Nginx, tune php.ini, and test the result. If your application needs PHP 8.4 or an older branch, read the section on older versions: the popular Ondřej Surý PPA doesn’t provide packages for Ubuntu 26.04 yet.

Last tested: November 2026 on Ubuntu 26.04.1 LTS with PHP 8.5.4.

Which PHP Version Can You Install on Ubuntu 26.04?

Each PHP branch gets two years of active support and then two more years of security-only fixes. This is what you can install on Ubuntu 26.04 as of November 2026:

VersionSecurity support untilOn Ubuntu 26.04
PHP 8.6Dec 31, 2030Released November 2026. Not packaged for Ubuntu 26.04 yet
PHP 8.5Dec 31, 2029Ubuntu 26.04 default, installed with apt (this guide)
PHP 8.4Dec 31, 2028No apt package yet. Use Docker (see below)
PHP 8.3 and olderDec 31, 2027 or earlierNo apt package yet. Use Docker or Ubuntu 24.04

For new projects, PHP 8.5 is a good choice: it is supported until the end of 2029 and receives updates through normal Ubuntu upgrades. Read about the new features in PHP 8.6, and see the PHP release tracker for current point releases.

Prerequisites

  • A system running Ubuntu 26.04 LTS (desktop or server)
  • A user account with sudo privileges
  • An internet connection

Step 1 of 7Update Your System

Refresh the package index and apply pending updates before installing anything:

sudo apt update
sudo apt upgrade -y

If the upgrade installed a new kernel, reboot the server before moving ahead.

Step 2 of 7Install PHP 8.5 on Ubuntu 26.04

PHP 8.5 is in Ubuntu’s main repositories, so you don’t need to add any extra repository. Install the interpreter and its common files:

sudo apt install php8.5 php8.5-cli php8.5-common -y

The php8.5 package needs a server API, and apt picks the Apache module by default. If you plan to use Nginx, install php8.5-fpm together with it (or install only php8.5-cli for command-line use) so Apache isn’t pulled in:

sudo apt install php8.5-cli php8.5-fpm -y

Check the installed version:

php -v

PHP 8.5.4 (cli) (built: Oct 19 2026 14:35:18) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.4, Copyright (c), by Zend Technologies

The Built by Ubuntu line confirms that the package comes from Ubuntu’s repositories. Point releases and security fixes arrive with your regular sudo apt upgrade.

Step 3 of 7Install PHP Extensions

The base package is deliberately minimal, and most 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,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 uses.
  • OPcache caches compiled bytecode and is the biggest performance win on a production server. In PHP 8.5 it is built into PHP itself, so there is no php8.5-opcache package. Adding it to the list above makes apt stop with “Unable to locate package”. The “with Zend OPcache” line in php -v shows that it is active.
  • php8.5-mbstring, php8.5-xml and php8.5-curl are required by almost every framework and CMS.
  • Many PECL extensions are packaged too, for example php8.5-redis. Search with apt search php8.5- rather than guessing the name.

Step 4 of 7Configure PHP 8.5 with Apache

Skip this step if you use Nginx. To run PHP inside the Apache web server, install Apache and the PHP module:

sudo apt install apache2 libapache2-mod-php8.5 -y

The package enables the module automatically. Make sure it is active and restart Apache:

sudo a2enmod php8.5
sudo systemctl restart apache2

Step 5 of 7Configure PHP 8.5 with Nginx (PHP-FPM)

Nginx has no built-in PHP module, so it hands PHP requests to the FastCGI Process Manager (PHP-FPM). Install both, if you haven’t already (see our guide to Nginx on Ubuntu 26.04 for the web server setup):

sudo apt install nginx php8.5-fpm -y

Start PHP-FPM and enable it at boot:

sudo systemctl enable --now php8.5-fpm
sudo 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 -t
sudo systemctl reload nginx

The socket path contains the PHP version number. When you later move to another PHP release, update fastcgi_pass as well. Forgetting it is the most common cause of a 502 Bad Gateway error after a PHP upgrade.

Step 6 of 7Adjust PHP Settings

Each 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 check which file the CLI loads:

php --ini

Open the file for the server API 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 editor (Ctrl + X, then Y, then Enter). Restart the service so the changes take effect:

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 7 of 7Test Your PHP Installation

Create a small test file in your web root:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Open http://your-server-ip/info.php in a browser. You should see the PHP information page with PHP Version 8.5.4 (or newer) at the top, the loaded extensions and the active configuration file.

Once you have confirmed that everything works, delete the file. It exposes details about your server that are useful to an attacker:

sudo rm /var/www/html/info.php

Need PHP 8.4, 8.3 or Older on Ubuntu 26.04?

On Ubuntu 24.04 and earlier, the ondrej/php PPA is the standard way to install other PHP versions. As of November 2026, that PPA has no packages for Ubuntu 26.04: add-apt-repository ppa:ondrej/php adds the repository without an error, but apt skips it and sudo apt install php8.4 fails with “Unable to locate package”. You can check whether 26.04 builds have arrived. This command prints 200 once they are available, and 404 until then:

curl -s -o /dev/null -w "%{http_code}\n" https://ppa.launchpadcontent.net/ondrej/php/ubuntu/dists/resolute/Release

Some guides suggest pointing the PPA to noble (the Ubuntu 24.04 packages) instead. Don’t do this on a server you care about. Those packages are built against Ubuntu 24.04 libraries, and mixing releases leads to dependency conflicts and broken upgrades. Until the PPA supports 26.04, use one of these options:

Option 1: Run PHP 8.4 in Docker

The official PHP images on Docker Hub include every supported branch. First install Docker on Ubuntu 26.04, then run a script with PHP 8.4:

docker run --rm -v "$PWD":/app -w /app php:8.4-cli php -v

For a website, run PHP-FPM 8.4 in a container and let the Nginx on your host pass PHP requests to it. Mount the web root at the same path, so the file paths Nginx sends match the files inside the container:

docker run -d --name php84-fpm --restart unless-stopped -p 127.0.0.1:9084:9000 -v /var/www/html:/var/www/html php:8.4-fpm

Then use fastcgi_pass 127.0.0.1:9084; instead of the Unix socket in the Nginx server block from Step 5. To add extensions, build your own image from php:8.4-fpm and install them with the docker-php-ext-install helper that the image provides.

Option 2: Use Ubuntu 24.04 for That Application

Ubuntu 24.04 LTS is supported until 2029, and the PPA provides every PHP version from 8.5 down to 5.6 there. If an application needs an older PHP branch with native packages, keep it on a 24.04 server and follow our PHP on Ubuntu 24.04 guide.

We will update this guide with the PPA steps as soon as ondrej/php publishes packages for Ubuntu 26.04.

Conclusion

Installing PHP on Ubuntu 26.04 LTS is simple, because PHP 8.5 comes straight from Ubuntu’s repositories. You installed the interpreter and the extensions your application needs, connected PHP to Apache or Nginx, tuned php.ini and verified the result in a browser. Security fixes arrive with normal system updates. If an application still needs PHP 8.4 or older, run it in Docker or on Ubuntu 24.04 until the PPA supports 26.04.

Frequently Asked Questions (FAQs)

Which PHP version does Ubuntu 26.04 ship by default?

Ubuntu 26.04 LTS ships PHP 8.5. The unversioned php package depends on php8.5, and Canonical provides security updates for it for the life of the release. Run apt policy php8.5 to see the exact version your system offers.

Can I use the ondrej/php PPA on Ubuntu 26.04?

Not yet. As of November 2026, the PPA publishes packages for Ubuntu 24.04 and 22.04 only. Adding it on 26.04 doesn’t break anything, but it doesn’t make any extra PHP versions available either. Use the curl check in the section above to see when 26.04 builds land.

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 it 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, and is the recommended choice for anything beyond a small personal server.

I upgraded from Ubuntu 24.04. Will PHP 8.5 break my website?

A release upgrade replaces Ubuntu 24.04’s PHP 8.3 with PHP 8.5, so test your application first. Code that already runs cleanly on PHP 8.4 usually needs little or no work, but older code, abandoned plugins and unmaintained libraries are the usual sources of trouble. Test on a staging copy of the server, run your test suite, and check the error log with error_reporting set to E_ALL before you upgrade production.

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 redis
sudo 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 package can still be built with pecl after installing php8.5-dev.

Why does php -v show a different version than my website?

The php -v command reports the CLI binary, which is separate from what your site runs. With Apache, check that the php8.5 module is enabled. With Nginx, check that fastcgi_pass points at /run/php/php8.5-fpm.sock (or at your Docker container). Restart the web server after any change, then load a phpinfo() page to confirm.

How do I remove PHP 8.5?

Purge the packages and remove the dependencies that are no longer needed:

sudo apt purge 'php8.5*' -y
sudo apt autoremove -y

The purge also removes your configuration files under /etc/php/8.5, so back up anything you customised first.

Do I need Composer?

Most modern PHP applications manage their dependencies with Composer. It is a PHP script and runs under whichever php binary is the default. See how to install Composer on Ubuntu.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top