Step 1: Update Your Server
Start by ensuring your system is fully updated:
sudo dnf update -y
Step 2: Add Required Repositories
PHP 7.4 isn't available in AlmaLinux 9 by default, so we'll add two repositories: EPEL and Remi.
Install the EPEL repository:
sudo dnf install -y epel-release
Install the Remi repository:
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
Step 3: Install PHP 7.4
Now, install PHP 7.4 alongside your existing PHP version:
Enable the PHP 7.4 module from Remi:
sudo dnf module enable php:remi-7.4 -y
Install PHP 7.4 and common extensions:
sudo dnf install -y php74 php74-php-fpm php74-php-cli php74-php-mysqlnd php74-php-gd php74-php-mbstring php74-php-xml php74-php-opcache
This installs PHP 7.4 in a separate directory (/opt/remi/php74/) so it won't overwrite your existing PHP version.
Add any extra extensions you need (e.g., php74-php-curl or php74-php-zip) by including them in the command.
Verify PHP 7.4 is installed:
php74 -v
You should see output like: PHP 7.4.33 (cli). This confirms PHP 7.4 is ready.
Step 4: Set Up PHP-FPM for PHP 7.4
Virtualmin works best with PHP-FPM for multiple PHP versions. Start the PHP 7.4 FPM service:
Start and enable PHP 7.4 FPM:
sudo systemctl start php74-php-fpm
sudo systemctl enable php74-php-fpm
Check that it's running:
sudo systemctl status php74-php-fpm
Look for “active (running)” in the output.
Step 5: Update Virtualmin to Recognize PHP 7.4
Tell Virtualmin about the new PHP version:
Log in to Virtualmin via your browser.
Go to System Settings > Re-Check Configuration.
Click the button to re-check. Virtualmin will scan your system and list PHP 7.4 as an available version (e.g., 7.4 at /opt/remi/php74/root/usr/bin/php-cgi).
Step 6: Assign PHP 7.4 to a Website
To use PHP 7.4 for a specific site:
In Virtualmin, select the virtual server (domain) you want to use PHP 7.4 for.
Go to Server Configuration > PHP Versions.
From the dropdown, select 7.4 and save the changes.
Your site will now use PHP 7.4, while other sites can still use the default/latest PHP version.
Step 7: Test PHP 7.4
Confirm PHP 7.4 is working:
In the virtual server's public_html folder, create a file named info.php:
echo "<?php phpinfo(); ?>" > /home/[username]/public_html/info.php
(Replace [username] with the virtual server's username.)
Visit http://yourdomain.com/info.php in a browser.
Check that the page shows “PHP Version 7.4.x”.
Once confirmed, delete info.php for security:
rm /home/[username]/public_html/info.php