> ## Documentation Index
> Fetch the complete documentation index at: https://blog.onetsolutions.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Install PHP 8.6 on a Linux VPS and switch without downtime

> Install PHP 8.6 on a Debian, Ubuntu, AlmaLinux or Rocky Linux VPS next to your current version, then switch site by site. An OnetSolutions guide.

*Published on December 3, 2026*

Installing PHP 8.6 on a Linux VPS does not mean replacing the version you run today. PHP-FPM can run two versions side by side: each site picks its own through its socket, and rolling back is a one-line change.

PHP 8.6.0 was released on November 19, 2026. PHP 8.2, meanwhile, gets no more security fixes from the PHP project after December 31, 2026. And this autumn's vulnerabilities, such as [php2shell](https://blog.onetsolutions.net/en/php2shell-cve-2026-109618.md), were a reminder of what a maintained branch is worth.

This guide is for a Debian, Ubuntu, AlmaLinux or Rocky Linux VPS running nginx or Apache with PHP-FPM. The examples start from PHP 8.2 and the site `example.com`: adapt them.

## Which PHP versions are still supported?

php.net schedule, checked on December 3, 2026:

| Version | Bug fixes until | Security fixes until | Action |
| - | - | - | - |
| 8.2 | December 31, 2024 | **December 31, 2026** | Migrate now |
| 8.3 | December 31, 2025 | December 31, 2027 | Plan the migration |
| 8.4 | December 31, 2026 | December 31, 2028 | Test 8.6 alongside |
| 8.5 | December 31, 2027 | December 31, 2029 | Test 8.6 alongside |
| 8.6 | December 31, 2028 | December 31, 2030 | Target |

> [!NOTE]
>
> These dates are the PHP project's. A distribution may backport fixes to its own packages on its own schedule: check where your PHP comes from before drawing conclusions.

## Find the PHP version each site uses

`php -v` reports the command-line version, not the one behind your sites. Look for the running PHP-FPM services and the socket in each vhost:

```bash theme={null}
# Running PHP-FPM services
systemctl list-units --type=service 'php*fpm*'

# Debian, Ubuntu: socket used by each vhost
sudo grep -rnE 'fastcgi_pass|proxy:unix' /etc/nginx /etc/apache2 2>/dev/null

# AlmaLinux, Rocky Linux
sudo grep -rnE 'fastcgi_pass|proxy:unix' /etc/nginx /etc/httpd 2>/dev/null
```

**Good result:** each site points to a socket whose version you know, for example `/run/php/php8.2-fpm.sock` on Debian and Ubuntu, `/run/php-fpm/www.sock` on AlmaLinux and Rocky Linux.

> [!WARNING]
>
> **Debian, Ubuntu: a vhost that uses `/run/php/php-fpm.sock`, with no number, will change version by itself.** That link follows the highest version whose service is running. Replace it with the numbered socket of your current version and reload the web server **before** installing PHP 8.6.

## Check your code against PHP 8.6

With Composer, ask which packages refuse PHP 8.6:

```bash theme={null}
# From the project root
composer why-not php 8.6
```

The changes most likely to affect a site, from the [PHP 8.6 migration guide](https://www.php.net/manual/en/migration86.php) and the [UPGRADING](https://github.com/php/php-src/blob/PHP-8.6/UPGRADING) file:

| Change in PHP 8.6 | What may break | Action |
| - | - | - |
| `session.cookie_samesite` defaults to `Lax` | Payment or SSO returns sent by POST from another site: the session is no longer passed | `None` for that site, with `session.cookie_secure` set to `1` |
| `session.cookie_httponly` defaults to `1` | JavaScript that reads the session cookie | Fix the script, or set it back to `0` for that site |
| `session.use_strict_mode` defaults to `1` | Custom session handlers that accept externally supplied IDs | Implement `validateId()` and `create_sid()` |
| `trim()`, `ltrim()` and `rtrim()` also strip form feeds (`\f`) | Text processing that relies on them | Pass the character list as the second argument |
| `ValueError` or `TypeError` on invalid arguments that used to be tolerated | Sloppy calls to `scandir()`, `array_filter()`, `ZipArchive`… | Fix the reported call |
| Deprecated functions: `is_integer()`, `is_long()`, `is_double()`, `doubleval()`, `spl_object_hash()`, mbregex… | Nothing yet: a notice | Replace them at your own pace |

If you are coming from PHP 8.2, the [8.3](https://www.php.net/manual/en/migration83.php), [8.4](https://www.php.net/manual/en/migration84.php) and [8.5](https://www.php.net/manual/en/migration85.php) guides apply too: the changes add up.

> [!NOTE]
>
> **WordPress.** As of December 3, 2026, the [official compatibility table](https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/) stops at PHP 8.5, supported since WordPress 6.9 (labelled beta support at the time). PHP 8.6 is not listed yet. For a WordPress site leaving PHP 8.2, aim for a version in the table, 8.4 or 8.5: the method in this guide is the same, with that version's packages.

## Install PHP 8.6 alongside your current version

Take a [snapshot](https://help.onetsolutions.net/vps/snapshot) of the VPS before adding a repository.

### Debian and Ubuntu: the packages.sury.org repository

The [packages.sury.org/php](https://packages.sury.org/php/README.txt) repository ships PHP 8.6 for Debian 13 and 12, and for Ubuntu 26.04, 24.04 and 22.04 LTS. Its packages are built to coexist, one directory per version.

**Already using the `ondrej/php` PPA on Ubuntu 24.04 or 22.04?** It is [frozen and no longer receives updates](https://launchpad.net/~ondrej/+archive/ubuntu/php). Migrate with its maintainer's procedure, which removes and downgrades nothing:

```bash theme={null}
sudo apt update
sudo apt install debsuryorg-repository-php
sudo add-apt-repository --remove ppa:ondrej/php
sudo apt update
```

**Otherwise**, add the repository. These steps follow the official script in `README.txt`:

```bash theme={null}
sudo apt update
sudo apt install ca-certificates curl

# Repository signing key
curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb

# Declare the repository for your Debian or Ubuntu release
. /etc/os-release
sudo tee /etc/apt/sources.list.d/php.sources >/dev/null <<EOF
Types: deb
URIs: https://packages.sury.org/php/
Suites: ${VERSION_CODENAME}
Components: main
Signed-By: /usr/share/keyrings/debsuryorg-archive-keyring.gpg
EOF

sudo apt update
```

The `php8.6-cli` package registers itself as the `php` command with the highest priority. To keep your cron jobs on the old version during the migration, pin it first:

```bash theme={null}
# The "php" command stays on 8.2 until you say otherwise
sudo update-alternatives --set php /usr/bin/php8.2
```

Then install PHP 8.6 with the common extensions:

```bash theme={null}
sudo apt install php8.6-fpm php8.6-cli php8.6-mysql php8.6-curl php8.6-mbstring \
  php8.6-xml php8.6-zip php8.6-gd php8.6-intl php8.6-bcmath

# If your sites use them
sudo apt install php8.6-redis php8.6-imagick
```

The service is called `php8.6-fpm`, its socket `/run/php/php8.6-fpm.sock`. On an Apache server, the package enables nothing by itself: do not run `a2enconf php8.6-fpm`, which would switch every site without its own setting at once.

### AlmaLinux and Rocky Linux 9 and 10: Remi's php86 packages

Remi's repository offers two routes. The `php:remi-8.6` module **replaces** the system PHP. The `php86` collection installs **next to it**, under `/opt/remi/php86`: that is the one you want here.

> [!WARNING]
>
> **Apache: pin each site's version first.** The `php86-php-fpm` package drops `/etc/httpd/conf.d/php86-php.conf`, which sends `.php` files to PHP 8.6 server-wide from the next httpd reload. A setting inside a `<VirtualHost>` takes precedence: before installing, add the `<FilesMatch>` block from the Apache section below to each vhost, with the **current** socket `/run/php-fpm/www.sock`.

```bash theme={null}
# EPEL, then Remi's repository for your major version
sudo dnf install epel-release
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-$(rpm -E %rhel).rpm

# PHP 8.6 in parallel
sudo dnf install php86-php-fpm php86-php-cli php86-php-mysqlnd php86-php-mbstring \
  php86-php-xml php86-php-zip php86-php-gd php86-php-intl php86-php-bcmath

# If your sites use them
sudo dnf install php86-php-pecl-redis6 php86-php-pecl-imagick
```

With nginx, open `/etc/opt/remi/php86/php-fpm.d/www.conf`. The socket is only accessible to `apache` there: add `nginx`, or the site will answer 502.

```ini theme={null}
; /etc/opt/remi/php86/php-fpm.d/www.conf
listen.acl_users = apache,nginx
```

```bash theme={null}
sudo systemctl enable --now php86-php-fpm
```

The socket is `/var/opt/remi/php86/run/php-fpm/www.sock`, and the command line is called `php86`. The `php` command does not change.

### OPcache: nothing to install

Since PHP 8.5, OPcache is built into the binary and always loaded. There is no `php8.6-opcache` package to look for. If you carry over an old ini file, remove `zend_extension=opcache.so` from it: the line triggers a warning.

## Compare extensions and settings before switching

One missing extension is enough to cause a 500 error after the switch. Compare the two lists:

```bash theme={null}
# Debian, Ubuntu
diff <(php8.2 -m | sort) <(php8.6 -m | sort)

# AlmaLinux, Rocky Linux
diff <(php -m | sort) <(php86 -m | sort)
```

**Good result:** no `<` line matches an extension your sites need.

PHP 8.6 starts with its own `php.ini`. List your settings (`memory_limit`, `upload_max_filesize`, `post_max_size`…) and carry them over one by one, without copying the whole old file:

```bash theme={null}
# Debian, Ubuntu
diff <(grep -vE '^\s*(;|$)' /etc/php/8.2/fpm/php.ini) <(grep -vE '^\s*(;|$)' /etc/php/8.6/fpm/php.ini)

# AlmaLinux, Rocky Linux
diff <(grep -vE '^\s*(;|$)' /etc/php.ini) <(grep -vE '^\s*(;|$)' /etc/opt/remi/php86/php.ini)
```

Then check your code's syntax with the new binary, without touching the live site:

```bash theme={null}
# Replace php8.6 with php86 on AlmaLinux and Rocky Linux
find /var/www/example.com -name '*.php' -print0 \
  | xargs -0 -n1 php8.6 -d display_errors=1 -d log_errors=0 -d error_reporting=-1 -l \
  | grep -v '^No syntax errors detected'
```

**Good result:** no `Parse error` or `Fatal error` line. `Deprecated` lines are not blocking. This check only sees what compilation can detect: also run the project's test suite with `php8.6` if it has one.

## Prepare the site's PHP-FPM pool

If your sites share the `www` pool, carry its settings (`pm.max_children` in particular) over to PHP 8.6's `www.conf`.

If a site has its own pool, recreate it with **a different socket name**:

```bash theme={null}
# Debian, Ubuntu: reuse the site's pool
sudo cp /etc/php/8.2/fpm/pool.d/example.conf /etc/php/8.6/fpm/pool.d/example.conf
sudo nano /etc/php/8.6/fpm/pool.d/example.conf
```

```ini theme={null}
; Two versions cannot listen on the same socket
listen = /run/php/example-php8.6.sock
```

Test, then reload:

```bash theme={null}
# Debian, Ubuntu
sudo php-fpm8.6 -t && sudo systemctl reload php8.6-fpm

# AlmaLinux, Rocky Linux
sudo /opt/remi/php86/root/usr/sbin/php-fpm -t && sudo systemctl reload php86-php-fpm
```

> [!TIP]
>
> Create the pools for all your sites before the first switch. You will not have to reload PHP-FPM 8.6 again while it serves visitors.

## Switch a single site to PHP 8.6

Start with your least critical site. Only one line changes: the socket.

### With nginx

```nginx theme={null}
# In the site's PHP location block
# Old line, kept for rollback:
# fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_pass unix:/run/php/php8.6-fpm.sock;
```

On AlmaLinux and Rocky Linux, the line becomes `fastcgi_pass unix:/var/opt/remi/php86/run/php-fpm/www.sock;`. The old one is often `fastcgi_pass php-fpm;`.

```bash theme={null}
sudo nginx -t && sudo systemctl reload nginx
```

### With Apache

```apache theme={null}
# In the site's <VirtualHost>
<FilesMatch "\.php$">
    # Old line, kept for rollback:
    # SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost"
    SetHandler "proxy:unix:/run/php/php8.6-fpm.sock|fcgi://localhost"
</FilesMatch>
```

On AlmaLinux and Rocky Linux, the socket is `/var/opt/remi/php86/run/php-fpm/www.sock`.

```bash theme={null}
# Debian, Ubuntu
sudo apachectl configtest && sudo systemctl reload apache2

# AlmaLinux, Rocky Linux
sudo apachectl configtest && sudo systemctl reload httpd
```

A reload is not a restart: requests in progress finish with the old configuration, the next ones go to PHP 8.6. The old PHP-FPM keeps serving the other sites.

> [!NOTE]
>
> **PHP sessions.** On Debian and Ubuntu, both versions store their sessions in `/var/lib/php/sessions` by default: your visitors stay logged in. On AlmaLinux and Rocky Linux, `php86` uses its own directory, `/var/opt/remi/php86/lib/php/session`: with file-based sessions, they will have to log in again. Switch at a quiet time.

## Verify that the site runs PHP 8.6

Drop in a temporary script, query it, delete it:

```bash theme={null}
# Adapt the site root and the domain
echo '<?php echo PHP_VERSION, " ", PHP_SAPI, "\n";' | sudo tee /var/www/example.com/check-php86.php >/dev/null
curl -s https://example.com/check-php86.php
sudo rm /var/www/example.com/check-php86.php
```

**Good result:** `8.6.0 fpm-fcgi`, or a later 8.6 release. Behind a CDN, make sure the response does not come from the cache.

Then walk through what matters: login, forms, file upload, a test payment, an admin task. Keep the logs open meanwhile:

```bash theme={null}
# Debian, Ubuntu (apache2/error.log with Apache)
sudo tail -f /var/log/nginx/error.log /var/log/php8.6-fpm.log

# AlmaLinux, Rocky Linux
sudo tail -f /var/opt/remi/php86/log/php-fpm/www-error.log
```

Deprecations do not show up there: the packaged `php.ini` excludes them. To collect them on a staging site, add `php_admin_value[error_reporting] = 32767` to its pool.

## Roll back to the previous PHP version

Something wrong? Put the old socket back in the vhost, then:

```bash theme={null}
# nginx
sudo nginx -t && sudo systemctl reload nginx

# Apache (httpd instead of apache2 on AlmaLinux and Rocky Linux)
sudo apachectl configtest && sudo systemctl reload apache2
```

The old PHP-FPM never stopped running: the site returns to it as soon as the web server reloads. Fix the code or the missing extension, then try again.

| Symptom after the switch | Likely cause | Action |
| - | - | - |
| 502 Bad Gateway (nginx), 503 (Apache) | Socket missing or not accessible | `systemctl status` of the 8.6 service, socket path, `listen.acl_users` |
| `Call to undefined function` | Extension not installed for 8.6 | Install the `php8.6-…` or `php86-php-…` package, then restart PHP-FPM 8.6 |
| Session lost when returning from a payment | `session.cookie_samesite` set to `Lax` | See the compatibility table |
| File upload refused | Limits in the new `php.ini` | Carry over `upload_max_filesize` and `post_max_size` |

## Remove the old PHP version

Wait a few days after the last site. Check that nothing uses the old version any more, scheduled tasks included:

```bash theme={null}
# Debian, Ubuntu
sudo grep -rnE 'php8\.2|/php-fpm\.sock' /etc/nginx /etc/apache2 /etc/cron* /var/spool/cron /etc/systemd/system 2>/dev/null

# AlmaLinux, Rocky Linux
sudo grep -rnE 'run/php-fpm/www\.sock|fastcgi_pass +php-fpm' /etc/nginx /etc/httpd 2>/dev/null | grep -v php86
```

**Good result:** only commented lines and files shipped by the PHP packages themselves remain.

With Apache on Debian and Ubuntu, also check whether the old version's global configuration is enabled. Once every PHP site has its own `<FilesMatch>` block, disable it:

```bash theme={null}
# Shows php8.2-fpm.conf if it is enabled
ls /etc/apache2/conf-enabled/ | grep php

sudo a2disconf php8.2-fpm
sudo apachectl configtest && sudo systemctl reload apache2
```

Stop the service first, without uninstalling anything. It is your last safety net:

```bash theme={null}
# Debian, Ubuntu
sudo systemctl disable --now php8.2-fpm
sudo update-alternatives --auto php

# AlmaLinux, Rocky Linux: "mask", because nginx and httpd start php-fpm when they start
sudo systemctl mask --now php-fpm
```

If all is well, uninstall. Read the list of packages to be removed before confirming:

```bash theme={null}
# Debian, Ubuntu
sudo apt remove 'php8.2-*'

# AlmaLinux, Rocky Linux (php8.4-common if you use EL 10's PHP 8.4)
sudo systemctl unmask php-fpm
sudo dnf remove php-common
```

On AlmaLinux and Rocky Linux, the `php` command goes away with the old version. Use `php86` in your jobs, or install `php86-syspaths`, which makes the collection the system's default version.

## Common pitfalls

**Unnumbered metapackages.** In the Sury repository, `php`, `php-fpm` and `php-cli` now depend on PHP 8.6. If they are installed, a plain `apt upgrade` can bring in 8.6. Always name the version: `php8.6-fpm`.

**The Sury repository also updates your other PHP versions.** It publishes branches 8.2 to 8.5. Look at `apt list --upgradable` before running `apt upgrade`.

**Automatic updates skip third-party repositories.** The default `unattended-upgrades` origins only cover the distribution. Add the `deb.sury.org` origin, as explained in our [automatic updates](https://blog.onetsolutions.net/en/automatic-security-updates-linux-vps.md) guide.

**A copy of the vhost in `sites-enabled`.** On Debian and Ubuntu, nginx loads everything in that folder, `example.com.bak` included. Keep your copies elsewhere.

**Queue workers.** A worker started by Supervisor or systemd uses the `php` command, not the socket. It changes version when you change its binary and restart it.

**Adding up `pm.max_children`.** Two active PHP-FPM services share the same memory. Watch it while they coexist.

## Going further

* [Snapshots](https://help.onetsolutions.net/vps/snapshot) and [VPS backup](https://help.onetsolutions.net/vps/backup): a restore point before changing version
* [Operating systems](https://help.onetsolutions.net/vps/operating-system): the distributions available for your VPS
* [php2shell (CVE-2026-109618)](https://blog.onetsolutions.net/en/php2shell-cve-2026-109618.md): why a maintained PHP branch matters
* [PHP 8.5 vulnerability (CVE-2026-129474)](https://blog.onetsolutions.net/en/php-backtrace-cve-2026-129474.md): worth reading if you choose PHP 8.5
* [Slow Linux VPS](https://blog.onetsolutions.net/en/slow-linux-vps-find-cpu-ram-disk-network-bottleneck.md): measure the effect of the change on CPU and memory
* [What's new in PHP 8.6](https://www.php.net/releases/8.6/en.php): partial function application, `Time\Duration`, `clamp()`, the polling API

Have a question about a server hosted with us? [Our team is available](https://help.onetsolutions.net/console/support) from your client area.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.