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.
Pingback: How-to Easily Upgrade XAMPP on Windows - @SilasỌlátáyọ̀
imb
Thanks! This works perfectly.
pragnesh
it is better to use wamp server, just one client you can change to any 5.6, 7.0 or 7.1
XI
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.
Ch
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
Ch
Looks like a needed “LoadModule php7_module” instead of “LoadModule php5_module” in Line 19 in httpd-xampp7.conf/httpd-xampp71.conf, too.
XI
Yes, you need to change all relative paths appropriately as shown above.
You can use the original config file for reference.
Ch
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. 🙂
Ch
“php5_module”, this needs to be change to “php7_module”, too.
XI
I did mention it and I quote:
This statement applies to all the content in that section.
John Zimo
Yes it worked with me once I changed LoadModule php7_module 🙂
charlmert
Thank you, very helpful, really needed this
Joseph
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 forums
XI
Something is probably missing. Kindly post the content of your Windows Event Viewer to see the cause of the error.
Ogi22
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!
16:33:26 [main] XAMPP Installation Directory: “c:\xampp\”
16:33:26 [main] Checking for prerequisites
16:33:26 [main] All prerequisites found
16:33:26 [main] Initializing Modules
16:33:26 [main] Starting Check-Timer
16:33:26 [main] Control Panel Ready
After I click on Apache Start xampp tells me:
What log should I place here?
XI
What error are you getting when Apache is started?
Gerson Morales
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.
oswaldo soliz
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 cambie a xampp 7
C:/xampp (instalacion antigua)
C:/xampp7 (instalacion nueva “xampp7”)
Entonces con las rutas direccionadas correctamente lo ultimo que hice fue copiar la carpeta y el archivo que indicas.
belkashehajbsh
i do not have a php.ini in the version 7 and i dont know where to do the changes
Bryan Lopez
I have the same problem, how can we edit it??
XI
There is php.ini in version 7. What version of XAMPP are you using?