Webmin control panel allows you to run multiple PHP versions on the same server. You can choose different PHP versions for separate Virtual Servers (per domain and per directory).
Preliminary Requirements
Steps
1. Log into Your Server
Log in to your server with the root user. If you need instructions on how to log into a Linux-based server, refer to this guide.
2. Install PHP 5.6 on CentOS 7
yum install centos-release-scl
- Install the PHP packages:
yum install rh-php56 rh-php56-php-mysqlnd
3. Install a Second PHP Version
In this example, we will install PHP 7.2 on CentOS 7.
yum install centos-release-scl
- Install the PHP packages:
yum install rh-php72 rh-php72-php-mysqlnd
4. Enable suexec_module
on the Server
This will allow Webmin to recognize different PHP versions:
- Edit the Apache configuration file:
vi /etc/httpd/conf/httpd.conf
- Find and uncomment the line:
LoadModule suexec_module modules/mod_suexec.so
- Save and close the file.
- Restart Apache:
5. Log into Your Webmin Control Panel
If you haven't done it yet, refer to this guide.
6. Re-Check Configuration of the Server
- After logging into Webmin, go to Virtualmin, then navigate to
System Settings → Re-Check Configuration
.
- If you see the error:
Virtualmin is configured to setup DNS zones, but this system is not setup to use itself as a DNS server. Either add 127.0.0.1 to the list of DNS servers or turn off the BIND feature on the module config page.
- Click on “list of DNS servers” and add
127.0.0.1
to the DNS servers section, then press “Save”.
- Go back to
System Settings → Re-Check Configuration
and you should see something like this:
The following PHP versions are available: 5.5.38 (/usr/bin/php-cgi), 5.6.25 (/opt/rh/rh-php56/root/usr/bin/php-cgi), 7.2.10 (/opt/rh/rh-php72/root/usr/bin/php-cgi)
7. Modify Server Templates
- Navigate to
System Settings → Server Templates
.
- Select “Default Settings”.
- In the “Edit template section:” dropdown, choose “Apache website” and ensure the following setting is checked:
Automatically add appropriate SuExec directive? - Yes
- In the “Edit template section:” dropdown, choose “PHP Options” and ensure the following setting is checked:
Default PHP execution mode: CGI wrapper (run as virtual server owner)
- Press “Save”. From now on, all created Virtual Servers in Virtualmin will recognize different installed PHP versions.
8. Choose PHP Version for Your Domain or Directory
- Select the Virtual Server for which you want to choose the PHP version.
- Navigate to
Server Configuration → PHP version
.
- Here, you can select the PHP version for the entire domain and also choose different PHP versions for specific directories by entering the directory name.
By following these steps, you can effectively manage multiple PHP versions on your server using Webmin and Virtualmin.