This example shows how to install PHP 8.3 as a secondary PHP version on an Apache server without changing the system default PHP version. PHP 7.4 remains the default CLI version, while a specific website is configured to use PHP 8.3 through PHP-FPM.
Install PHP 8.3 FPM and Extensions
Install PHP 8.3 FPM together with the commonly required PHP extensions:
During installation, PHP displays the following notice because Apache is already installed:
Enable Apache FPM Modules
Enable the Apache modules required to communicate with PHP-FPM:
There is no need to enable PHP 8.3 globally when only selected VirtualHosts should use it.
Keep PHP 7.4 as the Default CLI Version
Set PHP 7.4 as the default version used by the php command:
This affects the command-line PHP interpreter. The Apache VirtualHost can still use PHP 8.3 independently through PHP-FPM.
Configure a VirtualHost to Use PHP 8.3
Add the following configuration under the DocumentRoot directive in the required Apache VirtualHost. In this example the configuration file is:
Add:
All PHP files for this VirtualHost will now be processed through the PHP 8.3 FPM socket:
Restart Apache
Restart Apache to apply the configuration:
PHP 8.3 FPM Configuration
The main PHP configuration file used by PHP 8.3 FPM is:
After changing this file, restart PHP-FPM and Apache for the changes to take effect:
Result
PHP 7.4 remains the system default for CLI commands, while the selected Apache VirtualHost runs PHP files using PHP 8.3 FPM. This makes it possible to run websites requiring different PHP versions on the same Apache server.