Install multiple version of PHP on Xampp

How to use multiple version of PHP on Xampp

Posted by Ervin Adams on November 18, 2022

Install multiple version of PHP on Xampp

How to use multiple version of PHP on Xampp

Posted by Ervin Adams on November 18, 2022

Xampp does not use multiple version of PHP out of the box. However, you may have projects that use different PHP versions.

Let's say you are currently on PHP 8 and you want to install PHP 7.

Here is how you install the different PHP versions you require:

Step 1. Go to  windows.php.net to download PHP version 

Based on your xampp set up you will have to choose NTS or TS version which stands for Non-Thread Safe and Thread Safe. You can check PhpInfo to verify.

Also x64 or x86 based on CPU architecture. 

Step 2. Extract the file and copy into the xampp directory

C:\xampp\php7_4

Step 3. configure php.ini file

Open C:\xampp\php7_4\php.ini, if that file does not exist you can rename php.ini-production into php.ini.

Then uncomment the line below:

extension_dir = "ext"

Also enable all the other required extension needed:

extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
extension=gd
extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=ldap
extension=mbstring
extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
;extension=oci8_19  ; Use with Oracle Database 19 Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
extension=pdo_sqlite
;extension=pgsql
;extension=shmop

; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=snmp

;extension=soap
;extension=sockets
;extension=sodium
;extension=sqlite3
;extension=tidy
;extension=xsl

;zend_extension=opcache

 Step 4. Configure Apache

Open Xampp control panel and click config button, then click Apache (httpd-xampp-conf)

The file httpd-xampp-.conf will open. Place the code snippet below:

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>

Listen 8888
<VirtualHost *:8888>
    UnsetEnv PHPRC
    <FilesMatch "\.php$">
        php_flag engine off
        SetHandler application/x-httpd-php74
        Action application/x-httpd-php74 "/php74/php-cgi.exe"
    </FilesMatch>
</VirtualHost>

Step 5. Restart Apache

Restart Apache and point your project to the port:

http://localhost:8888/project