Upgrade XAMPP the Clean Way

From time to time, I—and maybe you, too—want or have to upgrade XAMPP (i.e., install it again, in a newer version). I did this, for example, when switching PHP versions, or when I moved from MySQL to MariaDB. Instead of installing the new version on top of the current one, I decided to take another route, which I will explain in this very post.

It might be worth mentioning that I am writing this short tutorial mainly for the future me, although the post should be of good use to anyone with a similar setup. 🙂

The Current Situation

This tutorial, obviously, assumes you already have XAMPP installed, and one or more local hosts set up, which means there are custom files in htdocs/, and MySQL databases and tables created.

Of course, you also might have installed one or more additional PHP extensions, and customized or at least completed some config files for things like PHP, MySQL, or even the XAMPP Control Panel.

The Desired Situation

The goal is to have a clean XAMPP installation in your desired version, with all local hosts still working fine, and all of your current … let’s call it configuration.

What we do not want to have is a bloated xampp folder with lots of stuff that is old, outdated, obsolete and other words starting with “o”. 😉

Moving from A to B

Reaching the desired situation is really not that hard at all. And it only takes very few steps to cleanly upgrade XAMPP.

Taking Care of the Current Installation

There is one important thing that dictates what to do first: the type of update for MariaDB. If its version doesn’t change at all—very unlikely, though—or if the new version is a patch or minor update of the current one, then you don’t have to do anything special right now. A patch and also a minor update does not break any existing functionality, but only fixes bugs and/or introduces new features.

However, if the new version of MariaDB is a major update with respect to the current one, you should export all your databases.

After that, start XAMPP (i.e., the XAMPP Control Panel), stop all running services such as your Apache and MySQL server, then quit XAMPP. Finally, rename the folder that XAMPP is installed in, for example, to xampp.OLD/.

Installing XAMPP

Well, then, install XAMPP like the first time.

I only use the Apache and MySQL server, PHP, and phpMyAdmin. No need for an FTP server, Perl, Webalizer or any of the other available stuff. But you can, of course, do whatever you like here.

Adjusting the New Installation

Now, we only have to make sure the new installation behaves just like the old one, but … only in new. 😀 So, we would like to end up with a clean version of what we have when we regularly upgrade XAMPP.

Moving the (Local) Server Files

In order for both Apache and your operating system to work with your local hosts (i.e., the respective files), you have to move (or copy, if you want to be extra cautious) them from your old installation to the new one. By default, you will find them in htdocs/.

Moving the Databases

Now, this is the tricky part! Or not. It depends…

If you exported your databases before—because MariaDB was about to get a major update—you have to import them now, of course.

However, if you did not create any database dumps—meaning MariaDB only got a patch or minor update—all you have to do is to copy (or even move) the old data from the xampp.OLD/mysql/data folder to the new install (i.e., xampp/mysql/data). Done.

Taking Care of Your Configuration

Apache

Move your Apache hosts file, apache/conf/extra/httpd-vhosts.conf, to your new installation.

MySQL

Merge in any relevant changes in your MySQL config file, mysql/bin/my.ini. The only thing I did here was setting the max_allowed_packet size from the initial 1M to 32M.

PHP

You then want to take care of additional PHP extensions. Either move (or copy) them to you new installation (i.e., php/ext/), or even update them to the newest stable version. In my case, this is Xdebug.

After that, merge in any relevant changes in your PHP config file, php/php.ini. Since I had (in to too rare cases) trouble with larger plugin updates from a local WordPress website, I decided to set the max_execution_time to 90. I also set error_reporting to E_ALL. And, like mentioned before, I am using Xdebug, so I include the according configuration.

phpMyAdmin

Check if you did any customization to your phpMyAdmin configuration. Therefore, merge the phpMyAdmin/config.inc.php file. In my case, for example, I set some random password for the root user, because some app—I think it was Joomla—complained about using an empty string here. I also set a higher limit for the maximum execution time, by adding the following to the end of the file (replacing the closing ?> tag, if any):

$cfg['ExecTimeLimit'] = 90;
XAMPP

Not only services and web front ends (might) have been customized, but also XAMPP itself. To keep it, merge the XAMPP Control Panel config file, xampp-control.ini, directly in the xampp folder. Besides making both Apache and MySQL start automatically, I define Notepad++ to be my editor of choice (for config files).

Anything Else?

Depending on what you did to your XAMPP installation, there might be more stuff that you want to keep.

I am also using the Xdebug profiler from time to time, so maybe I still have some interesting Callgrind files somewhere—I output them to tmp/profiler/.

That’s It!

Well, that was all there is to do to cleanly upgrade XAMPP.

Open up your XAMPP Control Panel, start your desired services, and happy web developing! 🙂

If you have any comments, please let me know.


PS I actually moved away from XAMPP just yesterday, and started to manage Apache, MariaDB, PHP and phpMyAdmin as separate software installations from now on. Anyway, I nevertheless decided to finally finish and publish this post as it might be useful for someone else.

Leave a Reply

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