Php

Install PHP 8.6 on Linux Mint 22

Follow the official Sury instructions on Linux Mint 22 and apt update fails before a single PHP package arrives. The README builds the repository line from lsb_release -sc, Mint answers with its own codename instead of Ubuntu’s, and packages.sury.org has nothing published under that name. Once you point the repository at the Ubuntu base, PHP 8.6 installs cleanly, runs under Nginx and sits next to PHP 8.5 without a fight.

Original content from computingforgeeks.com - post 7394

We covered the repository fix, the CLI and extensions, local development with php -S and Composer, Nginx with PHP-FPM, switching versions and a real upgrade of a running 8.5 site. Everything was run on two fresh Linux Mint 22.3 VMs in November 2026 against PHP 8.6.0 from packages.sury.org. Short version: install it today for development, and hold production sites on 8.5 until the PECL extensions you depend on are built for 8.6.

Prerequisites

You need a Mint 22 machine with a sudo user and outbound HTTPS. Any Mint 22 point release behaves the same, because every one of them is built on Ubuntu 24.04 (noble), and noble is the codename the repository needs.

  • Linux Mint 22.x, Cinnamon, MATE or Xfce
  • A user with sudo rights
  • Port 80 free if you follow the Nginx section

If you are still on Mint 21, do the upgrade to Linux Mint 22 first and come back, since the steps here only target the noble base. Debian, Ubuntu and RHEL family readers have their own walkthroughs, linked in the closing section, because the repository setup differs on each.

Point the Sury repository at noble

Ondřej Surý’s packages are where current PHP for Ubuntu and Mint comes from, but the old ppa:ondrej/php is no longer the place to get them. Adding the PPA on Mint now prints a notice that it “is frozen and no longer receives updates” and sends new installs to packages.sury.org. The PPA page on Launchpad carries the same message, so skip the PPA entirely on a fresh machine.

Paste the Sury README as written and you get the result below. Mint reports zena as its codename, so the repository line points at zena and apt finds no Release file there.

lsb_release reports zena on Linux Mint 22.3 so the Sury PHP repository line points at a suite that has no Release file

The same /etc/os-release file that holds VERSION_CODENAME=zena also carries UBUNTU_CODENAME=noble, and noble is one of the suites packages.sury.org actually publishes. Reading that variable instead of calling lsb_release is the whole fix. Start with the helper packages and Sury’s signing key.

sudo apt install -y lsb-release ca-certificates curl
curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb

Next, write the repository file with the Ubuntu codename pulled from os-release and refresh the package lists. The subshell reads the variable without touching your current shell.

echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(. /etc/os-release; echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update

Confirm apt sees the new build before you install anything. The candidate should come from packages.sury.org/php noble/main, and the debsuryorg24.04 part of the version string tells you it is the noble build.

apt-cache policy php8.6

On our VM the policy read like this.

php8.6:
  Installed: (none)
  Candidate: 8.6.0-2+debsuryorg24.04.1+php+1
  Version table:
     8.6.0-2+debsuryorg24.04.1+php+1 500
        500 https://packages.sury.org/php noble/main amd64 Packages

The full sequence from the lab, with the corrected line and the policy check, is below for reference.

Sury PHP repository pointed at the noble suite on Linux Mint with apt-cache policy showing the PHP 8.6 candidate

One more thing about this repository: the plain php package follows whatever Sury makes the default. It still pointed at 8.4 during our lab run, and the noble index had switched it to 8.6 by 21 November, within two days of the release. So apt install php gives you 8.6 today, but through the php8.6 metapackage, which brings Apache along (more on that next). Always name the versioned packages, in your shell history and in any Ansible role that installs PHP, so the next default switch doesn’t change your PHP release behind your back.

Install PHP 8.6 on Linux Mint

Don’t install the php8.6 metapackage unless you want Apache. A dry run of it on Mint pulls apache2, apache2-bin and the APR libraries ahead of the PHP packages, and Apache then grabs port 80 before Nginx gets a chance. Install the CLI and the common files instead, and add FPM later when the web server is ready.

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

Check the version and where the php command now points.

php -v
readlink -f /usr/bin/php

You should see the build date, the Zend Engine version and an OPcache line, and the symlink should resolve to the versioned binary.

PHP 8.6.0 (cli) (built: Nov 18 2026 15:54:29) (NTS)
Copyright © The PHP Group and Contributors
Built by Ubuntu
Zend Engine v4.6.0, Copyright © Zend by Perforce
    with Zend OPcache v8.6.0, Copyright ©, by Zend by Perforce
/usr/bin/php8.6

That /usr/bin/php link is managed by update-alternatives, which matters once a second PHP version lands on the box. You will use it again in the side by side section.

php -v showing PHP 8.6.0 CLI with Zend OPcache on Linux Mint 22.3

With the interpreter in place, the extensions come next. Install them before you write any code, because the gaps on day one decide whether 8.6 can run your app at all.

Add the PHP 8.6 extensions

The core extensions are all there on day one. This set covers a typical Laravel, Symfony or WordPress app and installed in one transaction on Mint.

sudo apt install -y php8.6-mysql php8.6-pgsql php8.6-sqlite3 php8.6-curl php8.6-gd php8.6-mbstring php8.6-xml php8.6-zip php8.6-intl php8.6-bcmath php8.6-readline

Two habits from older guides break here. There is no php8.6-opcache package to install, because OPcache is compiled into the binary (you saw it in php -v), so asking apt for it fails with “Unable to locate package”. The bigger gap is PECL, where these extensions have no 8.6 builds yet and their apt-cache policy comes back empty.

  • redis and igbinary
  • apcu
  • imagick
  • xdebug
  • memcached

The capture below shows the opcache error, the empty policy output and a package count.

php8.6-opcache not found and no PECL packages for PHP 8.6, 32 php8.6 packages against 88 for PHP 8.5

Counting packages tells the same story: 32 php8.6 packages against 88 for php8.5. The 8.5 list carries amqp, mongodb, swoole, grpc, pcov and the rest of the third-party extensions that 8.6 is still waiting on. If your app needs one of those, read the upgrade section before you plan anything, because a missing extension does not fail politely.

To see what actually loaded, run php -m. On our VM it listed bcmath, curl, gd, intl, mbstring, mysqli, pdo_mysql, pdo_pgsql, pdo_sqlite, sodium, zip and the rest of the core set, plus the lexbor and uri modules, with Zend OPcache under the Zend Modules header. If an extension you installed is missing from that list, its ini file in /etc/php/8.6/cli/conf.d/ is the first place to look.

Test PHP 8.6 locally with php -S and Composer

On a Mint desktop you mostly need the CLI and the built-in server. A short script makes a quick smoke test of the new language features, so you know the binary really is 8.6 and not an older one earlier in your PATH. Save this as ~/demo/features.php.

<?php
$versions = ['8.4', '8.5', '8.6', '8.7', '9.0'];
$supported = array_filter($versions, version_compare(?, '8.6', '>='));
echo implode(' ', $supported), PHP_EOL;

echo clamp(150, 0, 100), PHP_EOL;

$timeout = \Time\Duration::fromSeconds(2)->add(\Time\Duration::fromMilliseconds(500));
printf("%d.%09d seconds\n", $timeout->seconds, $timeout->nanoseconds);

The version_compare(?, '8.6', '>=') line is partial function application, which hands array_filter a callable with the first argument left open. clamp() and the \Time\Duration class are new as well, so on 8.5 this file fails to parse. Run it with the default php.

php ~/demo/features.php

Three lines back means all three features work.

8.6 8.7 9.0
100
2.500000000 seconds

For a browser test, put an index.php under ~/demo/public that prints PHP_VERSION and PHP_SAPI, then start the development server from ~/demo. Keep it bound to 127.0.0.1, because php -S is single-threaded and was never meant to face a network.

php -S 127.0.0.1:8000 -t public

From a second terminal, curl -s http://127.0.0.1:8000/ returned the version with cli-server as the SAPI. The server log in the first terminal shows each request with its status code.

PHP 8.6 partial function application, clamp and Time Duration test output plus the php -S development server log

Watch one quirk while you test routes. A request for /missing.php also came back 200, because the built-in server falls back to index.php when the docroot has one. A 404 check that passes under Nginx can look broken under php -S, and the other way round, so test error pages on the real web server.

Composer is the other daily tool. Mint inherits Ubuntu’s composer package, which works on 8.6 but dates from early 2024 and complains loudly.

sudo apt install -y composer
composer --version

Every run prints deprecation notices. A single composer show in a project with two packages produced 47, and composer require monolog/monolog produced 1,315. Nearly all of them come from code written before PHP 8.4:

  • implicitly nullable parameters in bundled libraries
  • the E_STRICT constant, deprecated since 8.4
  • spl_object_hash(), deprecated in 8.6 (most of the require run)
  • curl_close() during downloads

Despite the noise, the require still installed monolog and psr/log correctly.

Composer 2.7.1 from the Ubuntu archive printing deprecation notices on PHP 8.6 while still installing monolog

The notices are noise, not failures, so the apt build is fine for a quick test. For daily work you are better off with the installer from getcomposer.org, which keeps you on the current release rather than the one Ubuntu shipped in 2024.

Serve PHP 8.6 through Nginx and PHP-FPM

Installing nginx and php8.6-fpm by name keeps Apache off the machine; after this step dpkg -l apache2 found nothing installed. Both services start on their own.

sudo apt install -y nginx php8.6-fpm
systemctl is-active nginx php8.6-fpm

FPM listens on /run/php/php8.6-fpm.sock. Open the default site so Nginx hands .php requests to that socket.

sudo vim /etc/nginx/sites-available/default

Replace its contents with this server block. The fastcgi-php.conf snippet ships with Mint’s Nginx and sets the script path plus the 404 check for missing files.

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.php index.html index.htm;
    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.6-fpm.sock;
    }
}

Drop a one-line probe into the docroot so you can test the handoff without a browser.

echo '<?php echo PHP_VERSION, " ", PHP_SAPI, PHP_EOL;' | sudo tee /var/www/html/version.php

Test the config before reloading, so a typo does not take the running server down with it.

sudo nginx -t
sudo systemctl reload nginx
curl -s http://localhost/version.php

The probe should answer with the FPM SAPI, not cli. When you see fpm-fcgi, Nginx is talking to the 8.6 pool.

Nginx configuration test passing and version.php returning 8.6.0 fpm-fcgi on Linux Mint

A phpinfo() page gives the same answer in more detail. Create it with echo '<?php phpinfo();' | sudo tee /var/www/html/info.php and open http://localhost/info.php. Server API reads FPM/FastCGI and the loaded ini is /etc/php/8.6/fpm/php.ini. Delete it with sudo rm /var/www/html/info.php once you have looked, because it exposes your whole configuration to anyone who finds the URL.

phpinfo page showing PHP Version 8.6.0 with Server API FPM/FastCGI on Linux Mint served by Nginx

The FPM defaults in that php.ini are conservative, and most real apps outgrow them quickly.

  • memory_limit = 128M
  • upload_max_filesize = 2M
  • post_max_size = 8M
  • max_execution_time = 30

Rather than edit the packaged php.ini, put your overrides in a file such as /etc/php/8.6/fpm/conf.d/99-app.ini and restart php8.6-fpm. A separate file survives package upgrades untouched, and the upgrade section shows why that pays off. For server blocks per site, TLS and pool tuning, our Nginx with PHP-FPM on Linux Mint guide goes further than this single default site.

Run PHP 8.5 and 8.6 side by side

Each PHP version installs into its own paths (/usr/bin/php8.5, /etc/php/8.5/, its own FPM unit and socket), so adding 8.5 next to 8.6 changes nothing for the running site. Install its CLI and FPM.

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

The php command follows update-alternatives. Each package registers with a priority (85 and 86), and auto mode picks the highest, so 8.6 stays the default. To pin your shell to 8.5 for a while, set it by hand, and go back to auto when you’re done.

sudo update-alternatives --set php /usr/bin/php8.5
php -v | head -1
sudo update-alternatives --auto php

Both FPM pools run at once with their own sockets, which means Nginx can send one site to 8.5 and another to 8.6 just by changing fastcgi_pass.

update-alternatives switching the php command between PHP 8.5 and PHP 8.6 with both FPM sockets present

For scripts and cron jobs, call php8.5 or php8.6 directly instead of relying on the alternatives link. A cron line pinned to a versioned binary keeps working the day someone flips the default, so you never debug a nightly job that changed PHP under you.

Upgrade a PHP 8.5 site to 8.6

We tested the upgrade on a second Mint VM (web01) running a real 8.5 stack from the old PPA. It had FPM behind Nginx, the usual core extensions, redis and igbinary from PECL, and a 99-app.ini raising memory to 256M. Those last two are what make this harder than a package rename, so the order below matters.

  1. Check which packages exist for 8.6
  2. Install those and copy the ini overrides
  3. Run your code with full error reporting
  4. Switch the Nginx socket, then retire 8.5
  5. Move the repository off the frozen PPA

Each step below matches one line of that list, and you can stop after any of them without breaking the live site. The PPA still carried the 8.6 packages when we tested, so we upgraded from it first and moved the repository last. If your 8.5 already comes from packages.sury.org, skip the last step.

Don’t swap package names blindly

The obvious one-liner takes every installed php8.5-* package, renames it to php8.6-* and feeds the list to apt. Our first attempt did exactly that, and it went wrong in two stages.

Blind PHP 8.5 to 8.6 package swap aborting on missing php8.6-redis and php8.6-igbinary so php8.6-fpm never gets installed

Apt treats the whole list as one transaction, so the two missing PECL packages stopped it before php8.6-fpm or anything else got installed. The second mistake was switching Nginx anyway. With no 8.6 socket to talk to, the site went straight to an error page.

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.24.0 (Ubuntu)</center>

We pointed Nginx back at the 8.5 socket, made sure the 8.5 pool was running, and the site recovered at once. That is the reason to keep 8.5 installed and running until the new pool is proven, because your rollback stays this short only while the old socket still exists.

sudo sed -i 's#php8.6-fpm.sock#php8.5-fpm.sock#' /etc/nginx/sites-available/default
sudo systemctl enable --now php8.5-fpm
sudo systemctl reload nginx

With the site back on 8.5, you can install 8.6 properly.

Install only what exists for 8.6

Filter the list first. This loop checks each renamed package with apt-cache show, writes the ones that exist to a file and prints the ones that don’t.

for p in $(dpkg -l 'php8.5*' | awk '/^ii/{print $2}' | sed 's/^php8\.5/php8.6/'); do if apt-cache show $p >/dev/null 2>&1; then echo $p >> /tmp/php86-ok.txt; else echo "missing: $p"; fi; done; cat /tmp/php86-ok.txt

On web01 it flagged the two PECL extensions and kept twelve packages.

missing: php8.6-igbinary
missing: php8.6-redis
php8.6-bcmath
php8.6-cli
php8.6-common
php8.6-curl
php8.6-fpm
php8.6-gd
php8.6-intl
php8.6-mbstring
php8.6-mysql
php8.6-readline
php8.6-xml
php8.6-zip

Stop here if a missing line names something your code calls. An app that uses the redis extension for sessions or cache will throw fatal errors on 8.6, so either move it to a pure PHP client such as Predis or wait for the extension. If the missing ones are optional, install the rest and carry your ini overrides across, because conf.d is per version and 8.6 starts with none of them. Extension ini files in conf.d are symlinks, so listing regular files finds your own.

find /etc/php/8.5/fpm/conf.d/ -type f

On web01 that returned a single file, /etc/php/8.5/fpm/conf.d/99-app.ini. Install the filtered list, copy that file and restart the new pool.

xargs sudo apt install -y < /tmp/php86-ok.txt
sudo cp /etc/php/8.5/fpm/conf.d/99-app.ini /etc/php/8.6/fpm/conf.d/
sudo systemctl restart php8.6-fpm

Both pools are now running. Wait until systemctl status php8.6-fpm reports “Ready to handle connections” before you point Nginx at the new socket.

Read the deprecations before you switch

Run your code through the 8.6 CLI with every error level on before real traffic sees it. Our test file held patterns common in older apps, and php8.6 -l called it clean while the runtime raised four deprecations, so a lint pass in CI is not enough on its own.

php8.6 -d error_reporting=E_ALL -d display_errors=1 /home/josphat/app/legacy.php

Returning from a finally block, the third argument to define(), strcoll() and passing an object to http_build_query() all warn now.

PHP 8.6 deprecation warnings for return in finally, define third argument, strcoll and http_build_query with an object

Look at the string(6) "padded" line as well. The same file under 8.5 printed string(10), because trim() now strips form feeds too. That is a silent behaviour change rather than a warning, so no lint pass will ever catch it. The PHP 8.6 migration guide lists the rest.

Switch Nginx and retire the 8.5 pool

The cutover is one socket path. Change it, test, reload and check that both the version and your ini overrides came across.

sudo sed -i 's#php8.5-fpm.sock#php8.6-fpm.sock#' /etc/nginx/sites-available/default
sudo nginx -t
sudo systemctl reload nginx
curl -s http://localhost/version.php

Our second probe printed the memory limit and whether redis loaded. It came back 256M redis:false, so the ini file made it and the extension did not, exactly as the filter predicted. Once your site is confirmed on 8.6, stop and disable the old pool.

sudo systemctl disable --now php8.5-fpm

Afterwards only php8.6-fpm.sock is left in /run/php/.

Nginx switched from the php8.5-fpm socket to php8.6-fpm, serving 8.6.0 with the redis extension gone

Leave the 8.5 packages installed for a week or so. Rolling back is the same sed in reverse plus systemctl enable --now php8.5-fpm, and that only works while the old pool still exists.

Move off the frozen ondrej PPA

If your PHP came from ppa:ondrej/php, switch the repository now, because the frozen PPA will not ship the 8.6 security fixes. The PPA’s own migration path is the debsuryorg-repository-php package, which adds packages.sury.org and leaves installed packages alone.

sudo apt install -y debsuryorg-repository-php
sudo add-apt-repository --remove -y ppa:ondrej/php
sudo apt update

On Mint that apt update fails with the same zena error as the fresh install. The package’s postinst reads the codename with lsb_release -sc when it generates /etc/apt/sources.list.d/php.sources, so the file says Suites: zena and apt prints this.

Err:9 https://packages.sury.org/php zena Release
  404  Not Found [IP: 203.0.113.52 443]
E: The repository 'https://packages.sury.org/php zena Release' does not have a Release file.

Change the suite to noble and update again.

sudo sed -i 's/^Suites: zena$/Suites: noble/' /etc/apt/sources.list.d/php.sources
sudo apt update

The 8.6 packages you just installed keep their PPA version strings, and that is expected. The PPA builds of the php8.6-* packages sort higher than the sury.org ones, so apt keeps them and nothing gets downgraded.

debsuryorg-repository-php writes Suites zena on Linux Mint and changing it to noble completes the move off the ondrej PPA

The exception is php-common. Its PPA build (2:101~+ubuntu24.04.1) sorts below the sury.org one, so your next apt upgrade moves it across, which is harmless. Remember the sed edit too. The header of php.sources says to run dpkg-reconfigure debsuryorg-repository-php after a distribution upgrade, and on Mint that reads lsb_release again, so reapply the sed afterwards.

Troubleshooting

These are the errors we hit on the two VMs, with the fix for each. Most of them come back to the codename or to extensions that do not exist yet.

The repository ‘https://packages.sury.org/php zena Release’ does not have a Release file

The repository line uses Mint’s codename. In /etc/apt/sources.list.d/php.list replace zena with noble, or rewrite it with the UBUNTU_CODENAME command from the repository section. If your file is php.sources from the migration package, change the Suites line instead.

E: Unable to locate package php8.6-redis

The PECL extension has not been built for 8.6 yet. The same goes for igbinary, apcu, imagick, xdebug and memcached at the time of testing. Check again with apt-cache policy php8.6-redis after an apt update, and until a candidate shows up, keep that app on 8.5.

E: Unable to locate package php8.6-opcache

Nothing is wrong. OPcache is built into the 8.6 binary rather than shipped as a separate package. Take php8.6-opcache out of your install list or Ansible role and confirm with php -v, which prints the “with Zend OPcache” line.

502 Bad Gateway after pointing Nginx at php8.6-fpm.sock

Nginx is passing requests to a socket nobody listens on. Run systemctl status php8.6-fpm, and if it says “Unit php8.6-fpm.service could not be found”, the package never installed, usually because an earlier apt transaction aborted on a missing extension. Point fastcgi_pass back at the 8.5 socket, run sudo systemctl enable --now php8.5-fpm in case the old pool was stopped, reload Nginx, then install from the filtered list.

Keep production on 8.5 until PECL catches up

PHP 8.6 on Mint 22 is ready for development today. The packages are solid, FPM behaves exactly like 8.5 under Nginx, and running both versions side by side costs nothing. Production is a different call: a site that leans on redis, igbinary, apcu or imagick has no 8.6 builds to move to yet, and a careless upgrade turns that into a 502. Install 8.6 next to 8.5, test your code with full error reporting, and cut over one socket at a time once apt-cache policy shows every extension you need.

If you also run other distributions, our PHP guides for Ubuntu, Debian and Rocky Linux and AlmaLinux cover the repository quirks on each, which you will hit there with 8.6 too. And if you would rather catch up on the language than the packaging, our list of the best PHP books covers the modern releases.

Keep reading

Backup and Restore Linux Systems with Timeshift Debian Backup and Restore Linux Systems with Timeshift PHP2Shell (CVE-2026-109618, CVE-2026-109619): Check and Patch PHP Php PHP2Shell (CVE-2026-109618, CVE-2026-109619): Check and Patch PHP How To Install Wine on Linux Mint 22.3 / 22.2 / 22.1 Linux Mint How To Install Wine on Linux Mint 22.3 / 22.2 / 22.1 Upgrade Linux Mint 22.3 to Mint 27: Tested Path and Rollback Linux Mint Upgrade Linux Mint 22.3 to Mint 27: Tested Path and Rollback Patch PHP CVE-2026-115560 on RHEL, Rocky Linux and AlmaLinux AlmaLinux Patch PHP CVE-2026-115560 on RHEL, Rocky Linux and AlmaLinux Patch PHP CVE-2026-115560 on Ubuntu 26.04 / 24.04 / 22.04 Php Patch PHP CVE-2026-115560 on Ubuntu 26.04 / 24.04 / 22.04

Leave a Comment

Press ESC to close