DEV Community

Cover image for How to change PHP version in XAMPP for Windows
Yahaya Oyinkansola
Yahaya Oyinkansola

Posted on • Updated on

How to change PHP version in XAMPP for Windows

Have you ever wondered how to upgrade or downgrade your PHP version in XAMPP without having to install another XAMPP software?, Well i have and from most answers i saw online, the best option was to download an updated version of XAMPP, but looking at it, i knew there had to be a better way so i made some research and was able to figure it out. In this article, i would show you how i changed my PHP version from 7.4.15 to 8.0.19.

This is a screenshot of my current PHP version

Image of PHP 7

If you don't know your current PHP version, you can use this link to check it.

STEP 1

Download the PHP version you want to use, you can find the PHP version you want to download from PHP's download website for windows, but there is something you need to know before downloading any package, the download for a PHP version exists in 2 types - thread safe and non thread safe. Since you are using PHP with XAMPP, you are going to download the non-thread safe version because there is an apache file it has that would be used to configure XAMPP with PHP.

PHP non thread safe version

After locating it, download the zip file. If you are running on a 32-bit system, download the non-thread safe version labelled with x86.

Update

Depending on the PHP version you want to change to, you might need to download the Thread safe version instead if you downloaded the non thread safe version, and you didn't see the Apache file there.

STEP 2

After you have downloaded it, extract the zip file and rename the extracted folder to "php", open the folder to find the apache file i mentioned in step 1 as shown in the image below. Once you have seen it, move the php folder to your xampp folder. Remember to make sure the current php folder in the XAMPP folder is either removed or renamed to something else so that the name won't conflict with the one you are moving.

Apache file for XAMPP configuration

STEP 3

After moving the php folder into the XAMPP folder, open the folder and look for the php.ini config file. Whenever you download a PHP package, the php.ini file comes in two parts, php.ini-development and php.ini-production. These two config files represent the settings running on your development and production environments. Since you are using XAMPP, you would be using the development config file, so rename that config file to php.ini.

STEP 4

Open your XAMPP control panel. Under the actions option for Apache, look for the config button, click on it and select the Apache (httpd-xampp.conf) config file to open it. This is the file that XAMPP uses to configure PHP properly, look for the following:

LoadFile "C:/xampp/php/php7ts.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
Enter fullscreen mode Exit fullscreen mode
  • Change php7ts.dll to php8ts.dll
  • Change php7_module to php_module
  • Change php7apache2_4.dll to php8apache2_4.dll

NOTE - Search everywhere in the file for "php7_module" and change it to "php_module" as you might need to change it in some places.

STEP 5

After you have done all this, save the changes and restart your server, go back to this url and confirm that your PHP version has changed. if everything was done correctly, you should see that you have successfully changed your PHP version!

PHP version 8 image

Very easy and convenient. You can agree it is really not difficult to change your PHP version in XAMPP as it is quite simple to do. Connect with me on twitter and linkedin to find out more about me and my work.

Top comments (6)

Collapse
 
nayaunglin910 profile image
NayAungLin910

Thank you very much for writing this tutorial! And I have managed to change PHP version because of this.
But for my case, I have to download the Thread Safe version of php. And only then, I saw the necessary files required to go along with the tutorial.

Collapse
 
kansoldev profile image
Yahaya Oyinkansola • Edited

Glad that it you found this useful!. I use windows, probably the reason for using non thread safe version, do you use Mac?

Collapse
 
nayaunglin910 profile image
NayAungLin910

Oh! I also use Windows. Maybe the PHP webpage got updated? I am not sure. But, thank you really for the tutorial.

Thread Thread
 
kansoldev profile image
Yahaya Oyinkansola

You are welcome, Glad it could solve your problem

Collapse
 
loktpar profile image
Lokendra Parihar

this guide not working when I download non thread safe php 8.2 64 bit .zip version there is no apache file as you shown in your artical.

Collapse
 
kansoldev profile image
Yahaya Oyinkansola

You would have to download the thread safe version for this version of PHP you are using. The Apache dll file is in most non thread safe versions, this is the only exception I have come across so far