Installing and managing multiple PHP versions
Goal and boundaries
This server provides PHP 8.1 for one legacy site, PHP 8.4 as the CMS baseline, and PHP 8.5 for current application testing. Each site selects its runtime through ISPConfig and runs in its own PHP-FPM pool.
update-alternatives to switch the global php command as a way of changing websites. CLI PHP and a site’s PHP-FPM runtime are separate concerns.Version policy
| PHP | Role | Typical requirements |
|---|---|---|
| 8.1 | Legacy compatibility | Keep only for applications that cannot yet be upgraded. |
| 8.4 | Stable CMS baseline | Full CMS extension set, including Imagick and Redis. |
| 8.5 | Current development/testing | Use after application and dependency compatibility tests. |
Every active version needs FPM, CLI for diagnostics, and the extensions actually used by assigned applications. Avoid installing extensions merely because another version uses them.
bcmath for every active PHP version when an application uses bcadd(), bcsub() or other BCMath functions (for example tax and money calculations). It is a normal PHP extension, but it is not enabled by the PHP core installation.Install PHP-FPM and extensions
Install packages from the approved PHP repository for the target Debian release. The exact package source may differ for PHP versions not supplied by Debian itself.
CMS baseline example
apt install php8.4-bcmath php8.4-bz2 php8.4-cli php8.4-common php8.4-curl php8.4-fpm php8.4-gd php8.4-igbinary php8.4-imagick php8.4-intl php8.4-mbstring php8.4-mysql php8.4-opcache php8.4-readline php8.4-redis php8.4-xml php8.4-zipApply the same pattern to other versions
apt install php8.1-bcmath php8.1-cli php8.1-fpm php8.1-curl php8.1-gd php8.1-intl php8.1-mbstring php8.1-mysql php8.1-xml php8.1-zip
apt install php8.5-bcmath php8.5-cli php8.5-fpm php8.5-curl php8.5-gd php8.5-intl php8.5-mbstring php8.5-mysql php8.5-xml php8.5-zip
systemctl enable --now php8.1-fpm php8.4-fpm php8.5-fpmRegister each version in ISPConfig
Go to System → Additional PHP Versions and create one record per runtime. Set the handler to PHP-FPM and use the actual binary and configuration paths on the server.
| Field | Example for PHP 8.4 |
|---|---|
| PHP-FPM init script | php8.4-fpm |
| PHP-FPM pool directory | /etc/php/8.4/fpm/pool.d |
| PHP-FPM socket | /run/php/php8.4-fpm.sock |
| PHP-FPM php.ini path | /etc/php/8.4/fpm/php.ini |
| CLI binary | /usr/bin/php8.4 |
Repeat with the matching 8.1 and 8.5 paths. Save the record and let ISPConfig process the change before assigning it to a live site.
Select PHP per website
- Open Sites → Website and select the website.
- On the Options tab, set PHP to PHP-FPM.
- Select the correct entry under PHP Version.
- Save, wait for ISPConfig to write the vhost/pool configuration, then test the site.
Keep the legacy site isolated on PHP 8.1. Do not upgrade it just because newer versions are installed; first verify the framework, Composer dependencies, custom code, and scheduled commands.
Verify without exposing phpinfo()
php8.1 -v
php8.1 -r 'echo bcadd("1.20", "2.30", 2), PHP_EOL;'
php8.4 -r 'echo bcadd("1.20", "2.30", 2), PHP_EOL;'
php8.5 -r 'echo bcadd("1.20", "2.30", 2), PHP_EOL;'
php8.4 -m
php8.5 --ini
systemctl --no-pager status php8.1-fpm php8.4-fpm php8.5-fpm
find /run/php -maxdepth 1 -name 'php*-fpm.sock' -lsFor a site-level check, use an authenticated diagnostic endpoint or its application’s own status page, then remove it. Do not leave a public phpinfo() file in a production document root.
Maintenance and retirement
- Patch every installed PHP version, not only the default one.
- Record the PHP version required by every hosted application.
- After changing extensions or
php.ini, restart only the relevant FPM service. - Review PHP 8.1 sites regularly and plan their application upgrade before repository support ends.
- Remove an old PHP version only after no site, cron job, or CLI deployment command references it.
Result: sites can evolve independently while legacy compatibility remains explicit and contained.
There's nothing here.
No comments have been posted here yet.