Multiple PHP versions in single XAMPP on Windows

Mohit Mehta
2 min readApr 15, 2022

Now a days everybody requires multiple PHP versions for different projects. In the Linux system, it is very easy to install & run multiple PHP simultaneously. However in the windows, it requires to install different version of XAMPP but it’s not feasible every time. So I have came to another solution to run multiple PHP versions in single XAMPP.

So first of all, your system must have installed any version of XAMPP. Let’s assume it’s installed in C: Drive and currently it has PHP v7.2 and now we want to install PHP v8.0.

Step 1: Download the required PHP executable from official site of PHP. Make sure to download the ZIP file from Non Thread Safe section. Now create a new folder with name php80 inside C:\xampp and extract the downloaded zip file in this folder.

Step 2: Go to XAMPP control panel and edit httpd-xampp.conf and place below code at the end of file.

ScriptAlias /php8x0 "C:/xampp/php80"
Action application/x-httpd-php80-cgi /php8x0/php-cgi.exe
<Directory "C:/xampp/php80">
AllowOverride None
Options None
Require all denied
<Files "php-cgi.exe">
Require all granted
</Files>
</Directory>
<Directory "C:/xampp/htdocs/php80">
<FilesMatch "\.php$">
SetHandler application/x-httpd-php80-cgi
</FilesMatch>
</Directory>
XAMPP Control Panel

Step 3: Open the php.ini file from C:\xampp\php80. If this file is not present then rename the php.ini.development to php.ini and make these 2 changes.

extension_dir = "C:\xampp\php80\ext"curl.cainfo = "C:\xampp\apache\bin\curl-ca-bundle.crt"

Step 4: Restart the Apache service from XAMPP control panel

Step 5: Create a new folder php80 inside C:\xampp\htdocs. That’s it. Now in this folder, any PHP file will be executed by PHP v8.0. You can check this by making info.php file and run it via http://localhost/php80/info.php

Let me know your thoughts & suggestions in the comment.

Bonus 1: If you want to run PHP commands from CMD using 8.0 version then it can be used like

C:/xampp/php80/php.exe -v
C:/xampp/php80/php.exe info.php
C:/xampp/php80/php.exe artisan serve

Bonus 2: Composer with PHP v8.0 can be used as

C:/xampp/php80/php C:/ProgramData/ComposerSetup/bin/composer.phar create-project TestC:/xampp/php80/php C:/ProgramData/ComposerSetup/bin/composer.phar install

--

--