ppa:ondrej/php repository (on Debian, packages.sury.org), then install each version’s FPM package, for example sudo apt install php8.3-fpm php8.4-fpm. Each version runs as its own service with its own socket, such as /run/php/php8.4-fpm.sock. Point each site’s fastcgi_pass (Nginx) or SetHandler (Apache) at the socket for the version it needs.
Before you start
- Use a user with
sudo. If you areroot, leave outsudo. - Take a backup or snapshot first. Adding a repository can upgrade the PHP version you already run.
- Supported PHP branches today: 8.2 and 8.3 get security fixes only (until 31 December 2026 and 31 December 2027), 8.4 and 8.5 get full support. Avoid 8.1 and older; they are end-of-life upstream.
How to add the PHP repository
- Ubuntu
- Debian
How to install a second PHP version
Install the FPM package and the extensions your app needs, with the version in each name:php8.3-…, php8.5-… and so on. Each version gets its own files:
Check that both services run:
How to choose the PHP version per site
- Nginx
- Apache
In each site’s server block, set the socket for the version that site needs:
How to change the default PHP for the command line
Thephp command (used by Composer, cron jobs and WP-CLI) follows the Debian alternatives system:
php8.3 artisan migrate.
How to check it worked
Put a test file in the site’s web root:fpm-fcgi, for example 8.4.x fpm-fcgi.
How to run several PHP versions on AlmaLinux and Rocky
Use Remi’s repository, which installs extra versions as prefixed packages next to the system PHP:epel-release-latest-9 and remi-release-9. The PHP 8.5 FPM socket is /var/opt/remi/php85/run/php-fpm/www.sock and its configuration lives under /etc/opt/remi/php85. Use that socket in fastcgi_pass.
Frequently asked questions
Will adding the repository upgrade my current PHP?
It can upgrade the patch level and extensions of the version you already have. It does not switch your sites to a new major version; you choose that per site.Which extensions do I need for each version?
Extensions are per version. If a site needsmbstring on PHP 8.4, install php8.4-mbstring even if php8.3-mbstring is already there. List loaded modules with php8.4 -m.
How do I remove an old PHP version?
Switch every site away from it first, then runsudo apt purge 'php8.2*' and sudo apt autoremove.
Do php.ini changes apply to all versions?
No. Each version has its ownphp.ini and FPM pool. See increase PHP upload size.
Related guides
VPS and dedicated server guides
Every server guide in one place.
Install a LEMP stack
Nginx with PHP-FPM.
Install a LAMP stack
Apache with PHP.
Fix 502 Bad Gateway
Wrong socket name? Start here.
Update Linux packages
Keep every version patched.
Checked against the official PHP supported versions page, the deb.sury.org FAQ and Remi’s PHP 8.5 guides on 4 November 2026; Nginx and Apache per-site PHP-FPM configuration and
update-alternatives tested on Ubuntu 24.04 LTS with PHP 8.3. Adding the third-party repositories was not tested. Commands can differ on other distributions or releases.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026