🐧
Linux

Installing PHP and Switching Versions on Linux

πŸ“… 19 October 2026 ✏️ 19 October 2026 ⏱ 5 min leestijd

Learn how to install PHP and switch PHP versions on a Linux server, via Plesk or the command line, without breaking your site.

Different websites need different PHP versions: an old WordPress theme, for example, wants PHP 7.4, while a modern webshop benefits from PHP 8.2 or higher. On a Linux server, you can install multiple PHP versions side by side and set per domain which version is used. This can be done via the command line with package managers such as apt or yum, but also easily via a control panel like Plesk.

Why multiple PHP versions are needed

A shared server often runs dozens of websites, each with its own requirements for the PHP version. An outdated CMS can crash on a PHP version that’s too new, while a new framework requires that outdated PHP versions no longer be used due to security and speed. By installing multiple versions side by side, each website can run the version it needs, without affecting other sites on the server.

Website AWebsite BWebsite CPHP 7.4PHP 8.1PHP 8.3One Linux server

Installing PHP via the command line

On Debian- and Ubuntu-based systems, you usually use a repository such as OndΕ™ej SurΓ½’s PPA to make multiple PHP versions available. On RedHat-based systems such as CentOS or AlmaLinux, the Remi repository is often used.

1

Add repository

On Ubuntu, add the PPA with add-apt-repository ppa:ondrej/php and update the package list with apt update. On RedHat systems, first install the Remi repository.

2

Install the desired PHP version

For example, install PHP 8.2 with apt install php8.2-fpm php8.2-cli php8.2-mysql. Repeat this for every version you need side by side, such as php8.1 or php7.4.

3

Configure PHP-FPM pools

Each version runs as a separate PHP-FPM service with its own socket, for example /run/php/php8.2-fpm.sock. In your web server configuration (Nginx or Apache), point each site to the correct socket.

4

Set default version with update-alternatives

On the command line, set the active CLI version with update-alternatives --set php /usr/bin/php8.2. This determines which version runs when scripts are executed via cron or SSH.

πŸ’‘ Tip: Always test a new PHP version on a staging environment first before activating it on a production site, especially for older websites with outdated plugins.

Switching PHP version via Plesk

A control panel such as Plesk makes switching PHP versions much easier than working manually with the command line. You don’t need to manually manage repositories or FPM pools: this happens automatically in the background.

In Plesk, go to the domain, choose PHP Settings and select the desired version from a dropdown menu. This change immediately adjusts the web server configuration, without affecting other websites on the same server. At Tandata, you’ll find this setting under each domain in Plesk, including the corresponding PHP extensions per version.

Want to switch to a hosting provider where this kind of management is well arranged by default? Check out the options for web hosting or read how switching to Tandata works.

Managing PHP modules and settings

Besides the version itself, it’s important to enable the right PHP modules (extensions), such as mbstring, curl, gd or intl. Many CMS systems and frameworks clearly indicate which extensions are required.

In Plesk, you check the required extensions per domain within the same PHP settings page. Via the command line, you install an extension with, for example, apt install php8.2-gd, followed by a restart of the corresponding FPM service with systemctl restart php8.2-fpm.

Also pay attention to settings such as memory_limit, upload_max_filesize and max_execution_time. You can adjust these values per PHP version and even per domain, so that heavy applications are not limited by a default value that’s too low.

Frequently Asked Questions

Can I use multiple PHP versions simultaneously on one server?

Yes, that is in fact the standard way of working on a server with multiple websites. Each PHP version runs as a separate FPM service, so websites can use their own version independently of each other.

What happens if I switch the PHP version without testing?

Outdated functions or plugins can produce error messages or cause the website to fail completely. Therefore, always test on a copy of the site before changing the version on the live environment.

How do I know which PHP version my CMS needs?

Consult your CMS or framework’s documentation; it usually states a minimum and recommended PHP version. Plugins and themes may have additional requirements.

Does PHP version management also work for email scripts?

Yes, scripts that send forms via email, for example, also run under the domain’s configured PHP version. For separate email functionality, you can also look into business email with your own domain name.

Can I get help setting up PHP versions?

Yes, via the knowledge base you’ll find extensive explanations, and for specific questions, 24/7 support is available via WhatsApp, ticket, or email.

Conclusion

Installing PHP and switching between versions on Linux can be done both via the command line with package managers and via a user-friendly panel like Plesk. For most administrators, Plesk is the fastest and safest route, as FPM pools and web server configuration are automatically updated. Always test changes before applying them to a live website.

View web hosting β†’

Was dit artikel nuttig?