Multiple PHP version with XAMPP on Windows
Sometime we fall into a situation whereby we badly need to test our project in another PHP version to check if it’s safe across all recent/commonly used PHP versions. Well, that situation came across my path. I wanted to test my project compatibility with the new version of PHP (7.1.8 as of the time of writing this post). I did my first routine by visiting Google.com in-search for an easy way out. Most of the article I came by are more focused on running multiple version of XAMPP on Windows e.t.c and not about having multiple PHP version with XAMPP on Windows. I couldn’t find a suitable post going my direction so, I decided to think and rethink. All I wanted was an easy way to switch between multiple versions of PHP; I don’t want any simultaneous process nor do I want to install another MySQL or Apache server and so on.
Well, follow these easy steps to allow multiple PHP version with XAMPP on Windows.
Currently, I have XAMPP with PHP 5.6.31 installed on my Windows 10 workstation and I want to install PHP 7 alongside this installed version. So, the first step I took was to download the portable version of XAMPP on Apachefriends.org. I thought having PHP version 7.0.22 & 7.1.8 will be cool though (I have my reasons and it’s obvious).
When the download it completed, extract each files to there respective folders. You only need the php content from the portable versions of XAMPP downloaded. Rename the php folder to php7 and php71 respectively. (or any name you prefer)
First of all, STOP your Apache and MySQL server. Now copy each renamed PHP folder to your current XAMPP directory. You should have something like this:
With this in place, you will, therefore, need to make some changes to your Apache config files. To start with, open [DRIVE:\]xampp\apache\conf\extra and locate the httpd-xampp.conf.
Replicate this file by using Ctrl+c and Ctrl+v; you will need to do this for both version of PHP. Now, rename the two new copies to httpd-xampp7.conf and httpd-xampp71.conf respectively.
Open each file, that is “httpd-xampp7.conf” & “httpd-xampp71.conf”, and edit accordingly as depicted below.
Basically, all you need to do is change all the php path in each file, i.e D:/xampp/php/ to D:/xampp/php7/ and D:/xampp/php71/ respectively. Remember to change the .dll path to the appropriate one for the version of php. i.e /php5ts.dll to /php7ts.dll. You need to be careful though.
Please note: You are not to change all php content you see to php7 or php71; change only the paths as shown in the picture above.
Almost there. Next step is; open [DRIVE:\]xampp\apache\conf\httpd.conf file and search for # XAMPP settings
All you have to do is edit “conf/extra/httpd-xampp.conf” to the version of php you want to use. Remember the XAMPP settings files are named according to the version of PHP we have in the XAMPP directory.
So, anytime you want to alternate the version of PHP, just stop your Apache server and edit [DRIVE:\]xampp\apache\conf\httpd.conf file by changing “conf/extra/httpd-xampp.conf” to “conf/extra/httpd-xampp7.conf” or “conf/extra/httpd-xampp71.conf”.
Furthermore, before you do any START and STOP on your server, you need to change some settings in you php.ini files as well. Open your \xampp\php7\php.ini and \xampp\php71\php.ini files and edit these settings.
Find (use Ctrl+f or Ctrl+h in your editor)
include_path=D:\xampp\php\PEAR and replace with(=>) include_path=D:\xampp\php7\PEAR
extension_dir=”D:\xampp\php\ext” => extension_dir=”D:\xampp\php7\ext”
error_log=”D:\xampp\php\logs\php_error_log” => error_log=”D:\xampp\php7\logs\php_error_log”
zend_extension = “D:\xampp\php\ext\php_xdebug-xxxx.dll” => zend_extension = “D:\xampp\php7\ext\php_xdebug-xxxx.dll” [If using ZEND extension, please make sure you are using the right version of dll for the right php version to avoid problem]
Make sure you handle all php path correctly in each php.ini and httpd-xampp.conf files as well.
In conclusion, this is my method of using Multiple PHP version with XAMPP on Windows and this process seems so easy to me and I prefer it to the simultaneous server process. With this, you don’t need to use multiple port, Apache server or have another MySQL installation.
If you have any contribution or question, please SAY SOMETHING below. Thanks.
[…] […]
Thanks! This works perfectly.
it is better to use wamp server, just one client you can change to any 5.6, 7.0 or 7.1
I understand your WAMP option, but this is currently not available in XAMPP and this is why I created this tutorial. I personally prefer XAMPP to WAMP for so many reason.
Thanks for your contribution.
Hey,
I’ve used this. But after hitting the start button, the apache stop right after it and ask me to check ports and stuff. Common issue?
Regards
Looks like a needed “LoadModule php7_module” instead of “LoadModule php5_module” in Line 19 in httpd-xampp7.conf/httpd-xampp71.conf, too.
Yes, you need to change all relative paths appropriately as shown above.
You can use the original config file for reference.
The problem was not the path in that line, it was the “php5_module”, this needs to be change to “php5_module”, too. I forgot this, maybe you make a red box around it, too. 🙂
“php5_module”, this needs to be change to “php7_module”, too.
I did mention it and I quote:
This statement applies to all the content in that section.
Yes it worked with me once I changed LoadModule php7_module 🙂
This helped!
Thank you!
Thank you, very helpful, really needed this
Hi. I am installing from php7 to php5. When I restart Apache I get this error message. 9:37:18 p. m. [Apache] Error: Apache shutdown unexpectedly. 9:37:18 p. m. [Apache] This may be due to a blocked port, missing dependencies, 9:37:18 p. m. [Apache] improper privileges, a crash, or a shutdown by another method. 9:37:18 p. m. [Apache] Press the Logs button to view error logs and check 9:37:18 p. m. [Apache] the Windows Event Viewer for more clues 9:37:18 p. m. [Apache] If you need more help, copy and post this 9:37:18 p. m. [Apache] entire log window on the… Read more »
Something is probably missing. Kindly post the content of your Windows Event Viewer to see the cause of the error.
I have the same problem. I installed xampp-win32-7.2.2-0-VC15-installer on mi windows10 x64. After installing a port issue port 80 and 443 I fix with the following instructions: https://www.youtube.com/watch?v=_cu7KM0NsUA Then everything worked. Apache ran with the original php7.2.2. But I suddenly needed php7.0.24. I found your instructions and used it. But it does not work 🙁 I run xampp as an administrator. Xampp tells me: 16:33:26 [main] Initializing Control Panel 16:33:26 [main] Windows Version: Pro 64-bit 16:33:26 [main] XAMPP Version: 7.2.2 16:33:26 [main] Control Panel Version: 3.2.2 [ Compiled: Nov 12th 2015 ] 16:33:26 [main] Running with Administrator rights – good!… Read more »
What error are you getting when Apache is started?
Lo hice de la siguiente manera, ejecute la instalación de xampp con php7.0 colándola en un pendrive (en este caso E:/xampp), luego tome la carpeta de php y la copie en con el nombre php7 C:/xampp. => http://prntscr.com/ikvfmb
Seguidamente ubique el archivo httpd-xampp.conf (ubicado en E:/xampp/apache/conf/extra) y lo copie en C:/xampp/apache/conf/extra con el nombre httpd-xampp7.conf=> http://prntscr.com/ikvgpw
Ahora para usar php7 solo debo renombrar la carpeta de php7 a php y el archivo httpd-xampp7.conf a httpd-xampp.conf
http://prntscr.com/ikvjlz
http://prntscr.com/ikvkry
Para usar nuevamente php5.6 solo renombre las carpetas.
Y me funciona perfecto.
Espero les ayude.
Gracias, me sirvio, solo que hice una modificacion. Cuando lo instalas en el disco E: el path de algunos archivos como el php.ini se direcciona a ese disco. Para arreglar las rutas lo que hice fue renombrar el xampp que ya tenia instalado en el disco. De C:/xampp a C:/xampp5 luego instale el nuevo xampp con la ruta por defecto, para que los nombres de las rutas se preserven, entonces me quedo esto C:/xampp5 (instalacion antigua) C:/xampp (instalacion nueva “xampp7”) Volvi a renombrar las carpetas, para dejar el xampp 5 funcionando por defecto y el nuevo xampp que descargue lo… Read more »
i do not have a php.ini in the version 7 and i dont know where to do the changes
I have the same problem, how can we edit it??
There is php.ini in version 7. What version of XAMPP are you using?
There is a simple solution to run multiple php versions side by side posted here: HIDDEN
Sorry, this solution is for XAMPP not WAMP server…
Funny, this form capitalizes everything I write and there is nothing I can do to get lowercase letters. I installed the php 7.2 version of xampp and then I renamed and copied the php directory of my old (php5.6) xampp installlation and adapted php.ini and the httpd conf files according to the description in this article. Everything works – except that I get two error messages: Can’t find ordinal 407 in DLL-file C:\xampp\ext\php_curl.dll Can’t find ordinal 314 in DLL-file C:\xampp\ext\php_openssl.dll The error is obvious: the path is wrong. the ext subdirectory is below the php5 subdirectory. not directly below the… Read more »
Very good work. Keep it up
Thanks for this step by step tutorial. This works perfectly
I have xampp with php7..I downloaded php-5.6.39 since my older projects should run..made almost all the changes according to your suggestion but php.ini.Because in php-5.6.39 there are tow php.inidevelopment and production?which to choose?there is no php.ini.I tried php.ini development but could not locate any of those which you had told?Should we add these lines?
Make a copy of php.iniproduction and rename it to php.ini; then edit it.
Yes..by doing that I am getting it.I am running older php projects correctly by including httpd-xampp5.6.39.conf in the httpd-conf file. But tried to run a php file which pays the amount in payumoney(testing in a payment gateway through xampp)..I am getting these errors in spite of including httpd-xampp7.conf in the httpd-conf file and other settings. [Mon Dec 10 11:19:15.438739 2018] [mpm_winnt:notice] [pid 4596:tid 120] AH00455: Apache/2.4.34 (Win32) OpenSSL/1.0.2o PHP/7.0.32 configured — resuming normal operations [Mon Dec 10 11:19:15.438739 2018] [mpm_winnt:notice] [pid 4596:tid 120] AH00456: Apache Lounge VC14 Server built: Jul 15 2018 10:55:21 [Mon Dec 10 11:19:15.438739 2018] [core:notice] [pid… Read more »
This error is probably outside the scope of this tutorial. I think you are having SSL issue on your local server. You might want to google a solutions for that; on how to configure SSL on XAMPP.
the php 7.3.0 doesn´t have a php.ini, only has a php.ini-development and php.ini-production
Make a copy of php.iniproduction and rename it to php.ini; then edit it.
Getting Error: Apache shutdown unexpectedly.
I’ve double checked that all paths and references are updated to php7, and can’t see any errors in the Logs.
Main difference from your excellent write-up is that I can’t find
zend_extension = “D:\xampp\php\ext\php_xdebug-xxxx.dll” => zend_extension = “D:\xampp\php7\ext\php_xdebug-xxxx.dll”
in my php.ini
Could that be the problem?
You really don’t need to enable xDebuger if you don’t need it. If you want to, then you need to get the right version for your php version.
I have php7 and now I want to have php5 for older project, I do this way but when I start my xampp, I get these errors: 11:31:10 ب.ظ [Apache] Error: Apache shutdown unexpectedly. 11:31:10 ب.ظ [Apache] This may be due to a blocked port, missing dependencies, 11:31:10 ب.ظ [Apache] improper privileges, a crash, or a shutdown by another method. 11:31:10 ب.ظ [Apache] Press the Logs button to view error logs and check 11:31:10 ب.ظ [Apache] the Windows Event Viewer for more clues 11:31:10 ب.ظ [Apache] If you need more help, copy and post this 11:31:10 ب.ظ [Apache] entire log… Read more »
Excellent post, but how do you resolve the issue of access to databases? I just did everything in the post, so far so good, but how can I have 2 phpmyadmin … one that accepts version 5.3 of the phph and another that accepts version 7 of the php in the same xampp ???