With a single XAMPP installation, you have 3 options to run multiple PHP versions:
This is the most common use case.
You may have one or two old projects that require an older PHP version.
You can configure XAMPP to run that older PHP version only for specific project directories.
Useful when:
- You are upgrading an old project
- You need to test the same project in both old and new PHP versions
Example:
http://localhost/any_project/→ runs PHP 7http://localhost:8056/any_project/→ runs PHP 5.6
You can create a virtual host like:
http://localhost→ PHP 7http://localhost56→ PHP 5.6
Assume:
- XAMPP is running PHP 7
- You want to add PHP 5.6
-
Download the NTS (Non-Thread-Safe) version from:
- https://www.php.net/releases/
- (Use the archive for older versions)
-
Extract it to:
C:\xampp\php56
⚠️ Important:
The Thread-Safe version does NOT includephp-cgi.exe, which we need.
Open:
C:\xampp\php56\php.ini
If it does not exist:
- Copy
php.ini-development - Rename it to
php.ini
extension_dir = "ext"Open:
C:\xampp\apache\conf\extra\httpd-xampp.conf
If this line exists:
SetEnv PHPRC "\\xampp\\php"Comment it out:
#SetEnv PHPRC "\\xampp\\php"Open XAMPP Control Panel:
- Click Config (Apache)
- Open
httpd-xampp.conf
Add this at the bottom of the file:
ScriptAlias /php56 "C:/xampp/php56"
Action application/x-httpd-php56-cgi /php56/php-cgi.exe
<Directory "C:/xampp/php56">
AllowOverride None
Options None
Require all denied
<Files "php-cgi.exe">
Require all granted
</Files>
</Directory>💡 You can repeat this process for additional PHP versions (php54, php74, etc.)
Add this to the bottom of httpd-xampp.conf:
<Directory "C:\xampp\htdocs\my_old_project1">
<FilesMatch "\.php$">
SetHandler application/x-httpd-php56-cgi
</FilesMatch>
</Directory>
<Directory "C:\xampp\htdocs\my_old_project2">
<FilesMatch "\.php$">
SetHandler application/x-httpd-php56-cgi
</FilesMatch>
</Directory>Now only those directories will use PHP 5.6.
To run PHP 5.6 on port 8056, add:
Listen 8056
<VirtualHost *:8056>
<FilesMatch "\.php$">
SetHandler application/x-httpd-php56-cgi
</FilesMatch>
</VirtualHost>Now:
http://localhost/project→ Default PHPhttp://localhost:8056/project→ PHP 5.6
Create:
C:\xampp\htdocs56
Edit:
C:\Windows\System32\drivers\etc\hosts
Add:
127.0.0.1 localhost56
Add this to httpd-xampp.conf:
<VirtualHost localhost56:80>
DocumentRoot "C:\xampp\htdocs56"
ServerName localhost56
<Directory "C:\xampp\htdocs56">
Require all granted
</Directory>
<FilesMatch "\.php$">
SetHandler application/x-httpd-php56-cgi
</FilesMatch>
</VirtualHost>Now:
http://localhost→ Default PHPhttp://localhost56→ PHP 5.6
- Save all configuration files
- Restart Apache from XAMPP Control Panel
| Method | Best For |
|---|---|
| Directory-based | Running only specific legacy projects |
| Separate Port | Testing same project in multiple PHP versions |
| Virtual Host | Clean environment separation |
✔️ You now have multiple PHP versions running under one XAMPP installation.
Based on this StackOverflow answer: