Upgrading your XAMPP setup on Windows without losing anything

With the latest major release of PHP, being PHP8 just recently released, I decided it was time for an upgrade to my local development environment. Upgrading XAMPP is a task to be undertaken when you are not under pressure by other work. You need to take your time and backups can take a while. What seem like shortcuts may just come back to bite you later. Thanks to a really helpful article from WPMU DEV on How to Upgrade XAMPP for WordPress Without Losing Anything that I found 2 years ago, this process was far less time consuming than it could have been. Trying to find a detailed explanation of how to upgrade for a Windows setup that works is difficult. So I thought I would write this post to add my more recent experiences of the process, and reiterate some of the important points from the article. I am not going to cover every point in detail, if you need that I highly recommend reading the article. This is as much as anything a record for myself for next time I need to upgrade as to the things I have learnt. In essence it is not so much an upgrade as it is a thorough backup, uninstall and reinstall of the new version.

The 6 step process

  1. Backup your files
  2. Export your databases
  3. Uninstall the old version of XAMPP
  4. Install the new version of XAMPP
  5. Adjust PHP settings
  6. Restore your website files and databases
Then there are some optional extra steps depending on your setup that can involve tweaking a few other files eg httpd-vhosts.conf and getting the settings right so that startups run smoothly. Note: throughout this article I will refer to my install folder which is C:\xampp.

Step 1 - Backup your files

In the WPMU DEV article I refer to above, it says to backup your htdocs folder. The C:\xampp\htdocs folder is where all your website files are kept, but I prefer to go with the belt and braces method and I backup my entire XAMPP install folder, in my case C:\xampp. This way I have everything just in case I forget some config file that I may have also changed in the past, for some good reason that I have now forgotten about.

Step 2 - Export your databases

The temptation when backing up your MySQL databases is to export them all to 1 file because it is quicker. Yes, it is quicker to create, but it is a pain when you run into import issues eg due to the size of the file and timeouts etc. In the long run it is much better to create an export file for each database.

Make sure you save the export somewhere away from your current XAMPP install folder as this will be deleted during the upgrade.

Go to phpMyAdmin eg http://localhost/phpmyadmin/ to export each database click on a database in the list on the left hand side, and then click on the Export tab and at the bottom of the export page click on Go.

Once the database has finished exporting, repeat this for each database. You don’t need to export the following databases as they are system database that are created as part of the XAMPP install

  • information_schema
  • mysql
  • performance_schema
  • phpmyadmin
  • test

Step 3 - Uninstall the old version of XAMPP

To uninstall the older version of XAMPP, go to the install directory eg C:\xampp and run uninstall.exe. You will be asked if you want to delete the htdocs directory. At this point double check your backup is somewhere away from your previous xampp install directory, and once you have confirmed this click “Yes”. Now wait, and wait some more, as this could take a while depending on how many local websites and files you have in your htdocs folder. I had a lot.

Step 4 - Install the new version of XAMPP

You can download a new version of XAMPP from Apache Friends.

XAMPP for Windows versions

Although a little, ok a lot old, the WordPress.org article on installing XAMPP is still a good and relevant explanation for installing XAMPP for Windows.

Step 5 - Adjust PHP settings

Depending on your setup there may be a few things in the php.ini file that you need to tweak to make things work/run better. You can find the php.ini file in C:\xampp\php

For example you might want to increase the size of :

  • post_max_size to say 128M
  • upload_max_filesize to say 128M

If you use the default PHP mail() function with your setup you may need to reconfigure the email settings eg:

  • SMTP=smtp.yourdomain
  • smtp_port=587

For a more detailed discussion on how I set up mail to work on localhost have a read of my post “Sending email from localhost when using xampp on windows“.

Don’t forget if you have already started Apache for some reason, you will need to stop and start Apache before these settings will take effect.

Step 6 - Restore your website files and databases

First restore your website files. Find your backup of your original XAMPP installation and copy the contents of htdocs from the backup to your new install eg C:\xampp\htdocs. You don’t need to copy the following folders and files as they are part of the xampp install:
  • htdocs\dashboard
  • htdocs\img
  • htdocs\webalizer
  • htdocs\xampp
  • htdocs\favicon.ico
  • htdocs\index.php
  • htdocs\bitnami.css
  • htdocs\applications.html
Next restore your databases. Go to phpmyadmin and import the database files one by one from the Import tab. I disabled the Partial import ie I unchecked “Allow the interruption of an import is case the script detects it is close to the PHP timeout limit” and I unchecked “Enable foreign key checks”. Then click “Go” at the bottom of the page. Repeat for each database.

Optional Extras

At this point, hopefully you will be all good to go. But there are a few more things that you may need to do to make your life easier.

Restore virtual hosts file

Depending on your local setup you may make use of the virtual hosts file ie httpd-vhosts.conf, if you install xampp to C:\xampp for example found in C:\xampp\apache\conf\extra in which case you will need to find it in your backup and restore the content to the new version of xampp.

Set up SSL to work with localhost

Sometimes it is helpful to have SSL setup to work with localhost. For more information on how to do this, have a read of my post “Setting up a self-signed SSL certificate for localhost when using XAMPP on Windows“.

Run As Administrator

If you try to run the XAMPP control panel after install you are likely to see in the console log a message that:

You are not running with administrator rights! This will work for most application stuff but whenever you do something with services there will be a security dialog or things will break! So think about running this application with administrator rights!

xampp not running as admin message

An example of things breaking, is when you try to quit you may get the message every time.

Error: Cannot create file “C:\xampp\xampp-control.ini”.
Access is denied

xampp cannot create xampp-control ini access denied

You can overcome this by going to where XAMPP was install eg C:\xampp and right click on xampp-control.exe, choose Properties then go to the Compatibility tab and check the box next to “Run this program as an administrator”

run xampp as administrator

The only problem with this solution, is every time you run the control panel, depending on your Windows settings, you will get a User Account Control warning message, confirming that you want to allow the program to make changes to your computer.

UAC warning for running XAMPP

The solution is to install the modules eg Apache and MySQL to run as Services, as currently you would see a big red cross in the Service column of the control panel.

xampp now running as admin but

To install Apache and MySQL as a service simply click on the red cross for each and choose “Yes”.

click yes to install apache as service

When both are installed as a service you will then see 2 green ticks.

mysql and apache installed as service

Installing them as a service means you don’t need to run the control panel each time you want to work with your localhost as they will already be running. You can still run the control panel if you need to access things like to stop and start a service etc, but it is no longer necessary to have the control panel running all the time.

Related Reading

Summary

XAMPP seems more targeted towards Unix users and as such is a little light on detail for Windows users. This hopefully was a useful guide for Windows users on how to upgrade their install of XAMPP.

As I mentioned at the start it is not so much an upgrade process, as it is a step by step process, involving  backups, uninstalling the old version and installing the new version.

1 thought on “Upgrading your XAMPP setup on Windows without losing anything

Leave a Reply

Your email address will not be published. Required fields are marked *