Ubuntu 24.04 LTS installs PHP 8.3 and Ubuntu 26.04 LTS installs PHP 8.5, both straight from Ubuntu's own archive with apt-get install php8.3-fpm or apt-get install php8.5-fpm. For any other version, such as PHP 8.5 on 24.04 or PHP 8.4 on 26.04, note that Ondřej Surý's famous ppa:ondrej/php is now frozen: Ubuntu packages come from packages.sury.org instead, which serves jammy, noble and resolute.
We built this guide in two clean containers on 20 November 2026, one with Ubuntu 24.04.5 and one with Ubuntu 26.04.1, and every output below was copied from those runs. If you want a clean server to follow along on, our KVM VPS and VDS plans in Amsterdam, Dublin and Prishtina come with Ubuntu, full root access and a dedicated IPv4 and IPv6 address.
Key facts, checked 20 November 2026:
- Ubuntu 24.04 (noble) ships PHP 8.3.6. The current build is
8.3.6-0ubuntu0.24.04.14from noble-security; packages.ubuntu.com still showed the previous build, .13, when we looked. - Ubuntu 26.04 (resolute) ships PHP 8.5.4, current build
8.5.4-0ubuntu1.6from resolute-security (packages.ubuntu.com listed 1.5). - The Launchpad page of ppa:ondrej/php says the PPA "is frozen and no longer receives updates" and points new installs on Jammy, Noble and Resolute to packages.sury.org/php.
- On packages.sury.org, both noble and resolute offered PHP 5.6 to 8.6; the newest builds were 8.3.37, 8.4.28, 8.5.13 and 8.6.0.
- PHP 8.6.0 came out on 19 November 2026. php.net gives security support to 8.3 until 31 December 2027, 8.4 until 31 December 2028, 8.5 until 31 December 2029 and 8.6 until 31 December 2030 (php.net supported versions).
- Ubuntu's standard security maintenance runs to May 2029 for 24.04 and May 2031 for 26.04, and covers the Main repository; Universe gets security coverage through Ubuntu Pro (Ubuntu release cycle). In both releases
php8.x-cliis in Main whilephp8.x-fpmis in Universe.
Quick install
- Check which version your release offers:
apt-get update && apt-cache policy php. 24.04 says2:8.3+93ubuntu2, 26.04 says2:8.5+99ubuntu1.- Install Nginx with FPM by name, not with the
phpmetapackage:apt-get install -y nginx php8.3-fpm php8.3-mysql php8.3-curl php8.3-mbstring php8.3-xml php8.3-zip php8.3-gd php8.3-intl. On 26.04 write 8.5 instead of 8.3.- Point Nginx at
/run/php/php8.3-fpm.sock(orphp8.5-fpm.sock) and test withphp -vand a phpinfo page you delete straight after.- Need another version? Add packages.sury.org with its keyring, add the pin file shown below, then install
php8.5-fpmorphp8.4-fpmnext to the stock one.
Which PHP each Ubuntu LTS gives you
| Ubuntu release | Stock PHP (20 Nov 2026) | FPM socket | Standard support ends | Other versions |
|---|---|---|---|---|
| 24.04 LTS noble | 8.3.6-0ubuntu0.24.04.14 | /run/php/php8.3-fpm.sock | May 2029 | 5.6 to 8.6 from packages.sury.org |
| 26.04 LTS resolute | 8.5.4-0ubuntu1.6 | /run/php/php8.5-fpm.sock | May 2031 | 5.6 to 8.6 from packages.sury.org |
Ask the server, not a blog, because the build number moves with every security update. On the 24.04 container:
# as root, read-only
apt-get update
apt-cache policy php php8.3-fpm
php:
Installed: (none)
Candidate: 2:8.3+93ubuntu2
...
php8.3-fpm:
Installed: (none)
Candidate: 8.3.6-0ubuntu0.24.04.14
Version table:
8.3.6-0ubuntu0.24.04.14 500
500 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages
500 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages
8.3.6-0maysync1 500
500 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages
The 26.04 container answered 2:8.5+99ubuntu1 for php and 8.5.4-0ubuntu1.6 for php8.5-fpm, again from the -security pocket.
Why it still says 8.3.6
Ubuntu freezes the upstream version for the life of a release and backports fixes into it. php.net is at 8.3.37, but Ubuntu's 8.3.6 is not 31 releases behind on security: the 0ubuntu0.24.04.14 part counts the updates. apt changelog php8.3-fpm | head showed the latest entry as a noble-security upload headed "SECURITY UPDATE" with three CVE patches. What you do not get are upstream bug fixes and new features, which is the honest reason to move to a newer build.
Install PHP with Nginx and PHP-FPM
Skip apt install php on a web server. apt-cache depends php8.3 lists libapache2-mod-php8.3 first and php8.3-fpm second, and the same holds for 8.5 on 26.04, so the metapackage can drag Apache in. Name the parts instead (24.04 shown; replace 8.3 with 8.5 on 26.04):
# as root
apt-get install -y nginx php8.3-fpm php8.3-mysql php8.3-curl php8.3-mbstring php8.3-xml php8.3-zip php8.3-gd php8.3-intl
php -v
systemctl is-active php8.3-fpm nginx
ls -l /run/php/
0 upgraded, 39 newly installed, 0 to remove and 12 not upgraded.
...
PHP 8.3.6 (cli) (built: Nov 18 2026 23:42:07) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies
active
active
lrwxrwxrwx 1 root root 30 Nov 20 23:01 php-fpm.sock -> /etc/alternatives/php-fpm.sock
-rw-r--r-- 1 root root 5 Nov 20 23:01 php8.3-fpm.pid
srw-rw---- 1 www-data www-data 0 Nov 20 23:01 php8.3-fpm.sock
On 26.04 the same command set up 41 packages and printed PHP 8.5.4 (cli) (built: Nov 19 2026 00:22:49) with Nginx 1.28.3. The default pool, /etc/php/8.3/fpm/pool.d/www.conf, runs as www-data with pm = dynamic and pm.max_children = 5. Five workers is low for a busy shop; raise it once you know how much RAM each worker uses.
A site block that sends .php files to that socket, with shop.example standing in for your domain:
# as root
mkdir -p /var/www/shop.example
cat > /var/www/shop.example/index.php <<'EOF'
<?php
echo 'PHP ', PHP_VERSION, ' via ', PHP_SAPI, "\n";
echo 'php.ini: ', php_ini_loaded_file(), "\n";
EOF
cat > /etc/nginx/sites-available/shop.example <<'EOF'
server {
listen 80;
server_name shop.example;
root /var/www/shop.example;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
}
EOF
ln -s /etc/nginx/sites-available/shop.example /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
curl -s -H "Host: shop.example" http://127.0.0.1/
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
PHP 8.3.6 via fpm-fcgi
php.ini: /etc/php/8.3/fpm/php.ini
A 502 here means the socket name in fastcgi_pass does not match a running pool; our 502 Bad Gateway guide covers the other causes.
The phpinfo check, then delete it
phpinfo shows which SAPI and php.ini the web server really uses. It also shows every path and version to strangers, so it lives for seconds:
# as root
echo '<?php phpinfo();' > /var/www/shop.example/info.php
curl -s -H "Host: shop.example" http://127.0.0.1/info.php | grep -oE "(Server API|Loaded Configuration File|Scan this dir for additional .ini files) </td><td class=\"v\">[^<]*" | sed 's#</td><td class="v">#: #'
rm /var/www/shop.example/info.php
curl -s -o /dev/null -w "%{http_code}\n" -H "Host: shop.example" http://127.0.0.1/info.php
Server API : FPM/FastCGI
Loaded Configuration File : /etc/php/8.3/fpm/php.ini
Scan this dir for additional .ini files : /etc/php/8.3/fpm/conf.d
404
The 404 at the end is the proof that the file is gone.
Install PHP with Apache
Apache can talk to the same FPM service through proxy_fcgi, so you never need mod_php. Both servers want port 80, so we stopped Nginx first in the lab:
# as root
systemctl disable --now nginx
apt-get install -y apache2
a2enmod proxy_fcgi setenvif
a2enconf php8.3-fpm
systemctl reload apache2
echo '<?php echo "PHP ", PHP_VERSION, " via ", PHP_SAPI, "\n";' > /var/www/html/v.php
curl -s http://127.0.0.1/v.php
rm /var/www/html/v.php
Output: PHP 8.3.6 via fpm-fcgi. a2enmod also enabled proxy as a dependency and asked for a restart; a reload was enough. The conf that a2enconf turned on ships with php8.3-fpm and boils down to one handler: SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost" for files matching .+\.ph(?:ar|p|tml)$. dpkg -l 'libapache2-mod-php*' listed nothing, so no mod_php came along.
php.ini locations and the common extensions
Each SAPI reads its own file under /etc/php/<version>/. php --ini reports the CLI one; php-fpm8.3 -i | grep "Loaded Configuration File" reports the FPM one.
| Used by | File (24.04) | Stock limits we found | After editing |
|---|---|---|---|
| Websites via PHP-FPM | /etc/php/8.3/fpm/php.ini | upload 2M, post 8M, memory 128M | systemctl restart php8.3-fpm |
| Cron, Composer, artisan, wp-cli | /etc/php/8.3/cli/php.ini | upload 2M, post 8M, memory -1 (none) | nothing, next run reads it |
| 26.04 equivalents | /etc/php/8.5/fpm/php.ini, /etc/php/8.5/cli/php.ini | same FPM defaults (2M, 8M, 128M) | systemctl restart php8.5-fpm |
Leave php.ini alone and drop overrides into conf.d, which package upgrades never overwrite:
# as root
cat > /etc/php/8.3/fpm/conf.d/99-local.ini <<'EOF'
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 256M
EOF
php-fpm8.3 -t
systemctl restart php8.3-fpm
A test page then printed 64M 256M through the web, while php8.3 -r on the shell still said 2M -1: two SAPIs, two files. Large uploads also need client_max_body_size in Nginx, see our 413 fix.
The eight packages in the install line cover what WordPress, Laravel, Symfony and most shops check for: mysql brings mysqli and pdo_mysql, xml brings dom, simplexml and xmlreader, and php -m also listed curl, gd, intl, mbstring and zip. OPcache was already on with no extra package. Add php8.3-bcmath, php8.3-redis or php8.3-imagick only if your app asks.
Newer PHP: from ppa:ondrej/php to packages.sury.org
Most Ubuntu PHP guides still start with add-apt-repository ppa:ondrej/php. We ran it on 24.04 and the PPA printed its own notice: "This PPA is frozen and no longer receives updates", followed by the new address. Its Launchpad series list offers only Noble and Jammy, no Resolute (26.04). Use the repository's own install steps from README.txt, which work on both releases because lsb_release -sc fills in noble or resolute:
# as root
apt-get update
apt-get -y install lsb-release ca-certificates curl
curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
dpkg -i /tmp/debsuryorg-archive-keyring.deb
sh -c 'echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
apt-get update
apt-cache search --names-only '^php[0-9.]+-fpm$' | sort -V
We got Setting up debsuryorg-archive-keyring (2025.11.18), then Get:4 https://packages.sury.org/php noble InRelease, and the search returned thirteen FPM packages from php5.6-fpm to php8.6-fpm. The 26.04 container fetched resolute InRelease and showed the same list. php.net only supports 8.2 and newer, so treat 5.6 to 8.1 as a bridge for an old app, not a home.
Already using the PPA?
The PPA description gives a migration that keeps your installed packages. We ran it on 24.04 with the PPA active:
# as root
apt-get update
apt-get install -y debsuryorg-repository-php
add-apt-repository -y --remove ppa:ondrej/php
apt-get update
It installed debsuryorg-repository-php (2026.11.20+ubuntu24.04.1+deb.sury.org+1), removed /etc/apt/sources.list.d/ondrej-ubuntu-php-noble.sources, left a new php.sources in its place, and the next update hit https://packages.sury.org/php noble InRelease.
Pin the repository before you install anything
Straight after adding the repository, apt list --upgradable on 24.04 wanted to replace 14 PHP packages that Ubuntu had installed:
libgd3/noble 2.3.3-17+debsuryorg24.04.1+php+2 amd64 [upgradable from: 2.3.3-9ubuntu5]
php-common/noble 2:101+debsuryorg24.04.1+php+1 all [upgradable from: 2:93ubuntu2]
php8.3-cli/noble 8.3.37-2+debsuryorg24.04.1+php+1 amd64 [upgradable from: 8.3.6-0ubuntu0.24.04.14]
php8.3-fpm/noble 8.3.37-2+debsuryorg24.04.1+php+1 amd64 [upgradable from: 8.3.6-0ubuntu0.24.04.14]
...
On 26.04 it was 13, with php8.5 8.5.4 heading for 8.5.13. Your next apt upgrade would quietly move the stock PHP from Ubuntu's security team to a separately maintained repository. Maybe you want that; decide on purpose. To take only the extra version from sury, pin it. Here is the 24.04 file for adding PHP 8.5:
# as root
cat > /etc/apt/preferences.d/sury-php <<'EOF'
# Ubuntu keeps its own PHP 8.3 and libraries; PHP 8.5 and php-common come from sury.org
Package: *
Pin: origin packages.sury.org
Pin-Priority: 100
Package: php8.5* php-common
Pin: origin packages.sury.org
Pin-Priority: 500
EOF
apt-get update
Priority 100 means "only if Ubuntu does not have it"; 500 puts the named packages back on equal terms, and the higher version wins. The php-common part is the Ubuntu-specific catch. Our first pin listed only php8.5*, and the install failed:
The following packages have unmet dependencies:
php8.5-common : Depends: php-common (>= 2:95~) but 2:93ubuntu2 is to be installed
...
E: Unable to correct problems, you have held broken packages.
Ubuntu 24.04's php-common is too old for sury's 8.5. With php-common in the pin, apt list --upgradable showed only that one package and php8.3-fpm stayed on 8.3.6-0ubuntu0.24.04.14. On 26.04 the mirror image is Package: php8.4* php-common if you need 8.4 for an older app.
Two PHP versions side by side, one socket per site
# as root (24.04)
apt-get install -y php8.5-fpm php8.5-mysql php8.5-curl php8.5-mbstring php8.5-xml php8.5-zip php8.5-gd php8.5-intl
php8.5 -v
systemctl is-active php8.3-fpm php8.5-fpm
ls -l /run/php/ | grep sock
1 upgraded, 11 newly installed, 0 to remove and 12 not upgraded.
PHP 8.5.13 (cli) (built: Nov 18 2026 15:52:05) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.13, Copyright (c) Zend Technologies
with Zend OPcache v8.5.13, Copyright (c), by Zend Technologies
active
active
lrwxrwxrwx 1 root root 30 Nov 20 23:01 php-fpm.sock -> /etc/alternatives/php-fpm.sock
srw-rw---- 1 www-data www-data 0 Nov 20 23:01 php8.3-fpm.sock
srw-rw---- 1 www-data www-data 0 Nov 20 23:02 php8.5-fpm.sock
The "1 upgraded" is php-common. php8.5-gd ran on Ubuntu's own libgd3 2.3.3-9ubuntu5. On 26.04, php8.4-fpm installed the same way at 8.4.28 next to the stock 8.5.4.
The cleanest way to give a site its version is its own pool, with its own Linux user and socket. That keeps one hacked site from reading another site's files:
# as root
useradd --system --home /var/www/app.example --shell /usr/sbin/nologin app
mkdir -p /var/www/app.example
cp /var/www/shop.example/index.php /var/www/app.example/
chown -R app:app /var/www/app.example
cat > /etc/php/8.5/fpm/pool.d/app.conf <<'EOF'
[app]
user = app
group = app
listen = /run/php/php8.5-fpm-app.sock
listen.owner = www-data
listen.group = www-data
pm = ondemand
pm.max_children = 10
pm.process_idle_timeout = 30s
EOF
php-fpm8.5 -t
systemctl reload php8.5-fpm
sed 's#shop.example#app.example#g; s#php8.3-fpm.sock#php8.5-fpm-app.sock#' /etc/nginx/sites-available/shop.example > /etc/nginx/sites-available/app.example
ln -s /etc/nginx/sites-available/app.example /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
curl -s -H "Host: app.example" http://127.0.0.1/
curl -s -H "Host: shop.example" http://127.0.0.1/
NOTICE: configuration file /etc/php/8.5/fpm/php-fpm.conf test is successful
PHP 8.5.13 via fpm-fcgi
php.ini: /etc/php/8.5/fpm/php.ini
PHP 8.3.6 via fpm-fcgi
php.ini: /etc/php/8.3/fpm/php.ini
A whoami.php using posix_getpwuid(posix_geteuid()) on app.example answered user: app. pm = ondemand starts workers only when requests arrive, which suits many small sites. On Apache, put the same SetHandler "proxy:unix:/run/php/php8.5-fpm.sock|fcgi://localhost" inside a <FilesMatch "\.php$"> block in that site's VirtualHost; our new.example site answered PHP 8.5.13 via fpm-fcgi while the default site stayed on 8.3.6.
Choose the command-line version with update-alternatives
Installing 8.5 on 24.04 moved the plain php command to 8.5 too, because each version registers with its own priority:
# as root
update-alternatives --display php | head -8
update-alternatives --set php /usr/bin/php8.3
php -v | head -1
php - auto mode
link best version is /usr/bin/php8.5
link currently points to /usr/bin/php8.5
...
/usr/bin/php8.3 - priority 83
...
/usr/bin/php8.5 - priority 85
update-alternatives: using /usr/bin/php8.3 to provide /usr/bin/php (php) in manual mode
PHP 8.3.6 (cli) (built: Nov 18 2026 23:42:07) (NTS)
Your cron jobs and Composer runs follow that link, so check it after every new PHP install. Manual mode survives later installs. On 26.04, adding 8.4 left php on 8.5 in auto mode, because 85 beats 84. In crontabs, call php8.5 or php8.3 by full name and the question goes away.
Security updates with unattended-upgrades
Our 24.04 container image did not include unattended-upgrades, so we installed it. Its stock config allows noble-security plus the ESM origins, and /etc/apt/apt.conf.d/20auto-upgrades turns on the daily run. Packages from sury are not on that list. Add the origin, as root:
# as root
apt-get install -y unattended-upgrades
cat > /etc/apt/apt.conf.d/52unattended-upgrades-sury <<'EOF'
Unattended-Upgrade::Origins-Pattern {
"origin=deb.sury.org";
};
EOF
unattended-upgrade --dry-run -d 2>&1 | grep -E "Allowed origins|No packages found"
Allowed origins are: o=Ubuntu,a=noble, o=Ubuntu,a=noble-security, o=UbuntuESMApps,a=noble-apps-security, o=UbuntuESM,a=noble-infra-security, origin=deb.sury.org
No packages found that can be upgraded unattended and no pending auto-removals
Thanks to the pin, this patches PHP 8.5 from sury and leaves 8.3 to Ubuntu. One detail for the record: php8.3-cli comes from Main, php8.3-fpm from Universe. Both are built from the same php8.3 source package, and in our container both had the same security build, but only Main is inside Ubuntu's promised standard security maintenance. pro security-status shows how your packages split.
Remove a PHP version cleanly
Move sites off the version first, or they return 502 the moment the socket disappears. Find them with a capital -R, which follows the symlinks in sites-enabled:
# as root
grep -Rl "php8.5-fpm" /etc/nginx/sites-enabled/ /etc/apache2/sites-enabled/
apt-get purge -y 'php8.5*'
apt-get autoremove --purge -y
ls /etc/php/
systemctl is-active php8.5-fpm
grep listed app.example and new.example.conf; after moving those, the purge removed 11 packages and php8.5-fpm was inactive. /etc/php/8.5 was still there, holding only our hand-made pool.d/app.conf: purge deletes the files packages ship, not the ones you wrote. Delete that folder by hand once you are sure, and remove the matching block from the pin file.
Frequently asked questions
What PHP version does Ubuntu 24.04 use?
PHP 8.3. On 20 November 2026 the current package was 8.3.6-0ubuntu0.24.04.14 from noble-security. Ubuntu keeps the 8.3.6 base for the whole release and backports security fixes into it.
What PHP version comes with Ubuntu 26.04?
PHP 8.5. The php metapackage on 26.04 is 2:8.5+99ubuntu1, and on 20 November 2026 php8.5-fpm was 8.5.4-0ubuntu1.6 from resolute-security. The FPM socket is /run/php/php8.5-fpm.sock.
Does ppa:ondrej/php still work?
It still installs, but its Launchpad page says it "is frozen and no longer receives updates" and its series list has no 26.04. New installs should use packages.sury.org/php, which serves jammy, noble and resolute. Existing PPA users can switch with apt-get install -y debsuryorg-repository-php and then remove the PPA.
How do I install PHP 8.5 on Ubuntu 24.04?
Add packages.sury.org with its keyring package, create a pin that gives php8.5* and php-common priority 500 and everything else from sury priority 100, then run apt-get install -y php8.5-fpm plus the extensions you need. Without php-common in the pin, apt stops with an unmet dependency on php-common (>= 2:95~).
Can PHP 8.3 and 8.5 run on the same Ubuntu server?
Yes. Each version runs its own FPM service with its own socket in /run/php/ and its own folder in /etc/php/. In our test one Nginx site answered from 8.5.13 and another from 8.3.6 at the same time; you pick per site with the socket path.
Where is php.ini on Ubuntu?
Websites use /etc/php/8.3/fpm/php.ini on 24.04 and /etc/php/8.5/fpm/php.ini on 26.04; the command line uses the cli/php.ini next to it. Put changes in conf.d/99-local.ini and restart the FPM service.
Running Debian 13 instead? See our Debian guide, where the stock version and the repository details differ.
Need a hand?
For a test box or a couple of small sites, the stock PHP on a VPS with NVMe in Amsterdam, Dublin or Prishtina is plenty. For production PHP with many FPM workers, a shop or an agency server full of pools, a VDS with dedicated vCPU keeps response times steady because the cores are not shared. If you would rather have the stack built for you, from multi-version PHP to per-site pools and automatic updates, we do custom offers, custom setups and systems built for you, quoted per job: message us on Telegram or write to info@rscomputers-ks.com.