Download the required version of PHP from https://www.php.net/downloads.php. For PHP7+, you can download the Thread Safe version. For older PHP, try the Non Thread Safe version.
Create another folder in
C:\xampp
for this version of PHP apart from the existingC:\xampp\php
. E.g.,C:\xampp\php74
.Copy the downloaded version’s file into this folder
Create
php.ini
in this folder by duplicatingphp.ini-development
Edit
php.ini
and uncomment the lineextension_dir="ext"
Uncomment required extensions in the same
php.ini
. Refer to existing PHP version’s ini file to see which extensions to uncomment. For example, uncomment the lineextension=mysqli
.In the XAMPP Control Panel, click Config button for Apache and select
httpd-xampp.conf
Add the following lines to the (end of the) file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
ScriptAlias /php74 "C:/xampp/php74" Action application/x-httpd-php74-cgi /php74/php-cgi.exe <Directory "C:/xampp/php74"> AllowOverride None Options None Require all denied <Files "php-cgi.exe"> Require all granted </Files> </Directory> <Directory "C:\xampp\htdocs\project-folder"> <FilesMatch "\.php$"> SetHandler application/x-httpd-php74-cgi </FilesMatch> </Directory>
You can add a
project-folder
entry for each website that needs to be configured for this version of PHPIn
httpd-xampp.conf
file, comment the lineSetEnv PHPRC "\\xampp\\php"
(Comment character is #)Restart Apache
For other methods to configure multiple PHP versions, see this Stack Overflow thread.