In this article, we will learn about running two versions of PHP on the same Apache server. To manage many domains, the Apache webserver uses virtual hosts on a single instance.
Prerequisite: We will be using the XAMPP server to use the Apache server and some knowledge to use it.
First, download the older version of XAMPP that can be of any version. The old version is XAMPP 1.8.2 and then later we install the latest version of the XAMPP. Both versions of the XAMPP will have the same apache server.
Steps:
-
Download xampp-win32-1.8.2-6-VC9-Installer.exe
-
Install the software.
-
Click on the next.
-
Change the name (better to use the XAMPP_1_8_2) so that later you will be able to differentiate between the new and old versions.
-
Click on “install” to complete the installation process.
- Open the folder location where you kept your XAMPP1_8_2.
- Click on the Apache at the XAMPP_1_8_2 –> apache
Configure the file httpd CONF file to change the port for the new XAMPP. As two different versions of XAMPP cannot run on the same port, we need to change to the port.
Steps to change the port for the XAMPP1_8_2:
Open the file HTTP CONF file > change the port from the 80 to 8080.
- After changing the port click on save and exit.
- Now go to the extra folder
- Changes to be done in the ssl CONF file
- Change the Listen 443 to 444
- Save all and exit.
- Now download the XAMPP new version
- Follow the same steps {1, 2, 3, 4, 5, 6}
- Don’t change anything like the port.
- Open the XAMPP1_8_2 control
- Open the XAMPP new version control.
Note: You may face some problem with the port of 3306.
Change the port 3306 to 3307
Steps to change port:
-
Change the config file for the MySQL in “my.ini” file.
-
Change the port to 3307
-
Run the code:
PHP
<?php
phpinfo();
?>
-
Save the above code in “htdocs” folder of the XAMPP folder for the new and older version.
-
Save in “htdocs” folder of the XAMPP folder.
-
Similarly with XAMPP_1_8_2
Now, open the browser then type the command .
localhost/phpinfo.php
Output:
This is the one version 7.4.2.
Now for the second version type the command .
localhost:8080/phpinfo.php
Output:
Finally we are able to execute the two PHP version (7.4.2 and 5.4.27) in the same Apache server.