How to Upgrade XAMPP for WordPress Without Losing Anything
How to Upgrade XAMPP for WordPress Without Losing Anything
There are a lot of things to love about XAMPP, but the update process is not one of them. There’s nothing automatic about it, and you can go ahead and plan on hitting a few bumps along the way.
In this tutorial, I’ll walk you through the process so you can get XAMPP up-to-date with minimal hassle – and without tearing your hair out.
You might be asking yourself, “Why not just follow the official documentation”? And that’s a very reasonable question. XAMPP is a community-driven project. As such, it doesn’t have corporate backing and plenty of financing. One of the byproducts of this arrangement is that things you would expect a commercial project to offer – such as detailed documentation – aren’t available for XAMPP. Go looking for official documentation on how to upgrade to the latest version of XAMPP and you won’t find any.
Support for XAMPP is limited to the community forums and a brief FAQ at the Apache Friends website. If you search for “update XAMPP” what you’ll find is a smattering of hits at the XAMPP forum and StackOverflow offering suggestions ranging from “just install the new version over the older one” (please don’t try this!) to “you can’t update without losing everything” and every possible answer in between.
Why Update XAMPP?
This might leave you wondering why you’d bother updating XAMPP at all. Do you even need to?
The biggest reason to update XAMPP is to get access to a newer version of PHP. Since XAMPP doesn’t update automatically, if you’ve been using XAMPP for a couple of years you’re probably running a badly outdated version of PHP. New versions of XAMPP are available running PHP 5.6 and even PHP 7.
Another reason to update is that you should always try to use the same version of PHP in your development environment and live on the web server. If your web server is running PHP 5.6, you’ll avoid any PHP surprises cropping up when you migrate a website by running the same version in your local development environment.
So what’s a WordPress developer to do? Luckily, you read WPMU DEV and this tutorial will you through the process of updating XAMPP without losing a single one of your WordPress websites.
Updating XAMPP is a six step process:
- Backup your website files.
- Export your databases.
- Uninstall the old version of XAMPP.
- Install the new version of XAMPP.
- Adjust PHP settings.
- Restore your website files and databases.
Step 1: Backup Website Files
All of your XAMPP website files live inside of the \xampp\htdocs\ directory. If you have more than one WordPress installation or website set up in this folder you’ll have a subdirectory for each installation or website. Take a look at the htdocs directory and determine which websites files you wish to keep.
To backup the files you wish to keep, create a new folder and copy the files you wish to keep into the new folder.
In my case, I wanted to keep all of my websites files except for those that were part of the XAMPP installation: dashboard, img, webalizer, xampp, and so forth. I created a backup folder called XAMPP Backup on my desktop and copied all of the files I wanted to keep directly into this folder.
Step 2: Export Databases
Fire up XAMPP control panel if it isn’t already running and head to phpMyAdmin. There are several ways to launch phpMyAdmin: by using the link in the XAMPP dashboard that appears at http://localhost, by clicking Admin in the MySQL row in the XAMPP control panel, or by just typing http://localhost/phpmyadmin into your browsers address bar.
You have two different options when it comes to exporting your databases. The first option is to export all of your databases in one SQL file. The second option is to export each database individually.
While option one may sound like the easier option, the downside is that since you’ll be working with a larger file you are more likely to run into issues when importing your databases into your new XAMPP installation. I’ve used both methods, and I usually recommend going with option two. It’s a bit more work to export and import your databases individually, but you’re also less likely to run into errors.
Here are the steps to take to download all of the databases at once:
- From the main phpMyAdmin page select Export.
- Select the Custom export method.
- In the Databases section, hold down Ctrl and select all of the databases you wish to export being careful not to select the database named phpmyadmin.
- Scroll to the bottom of the page and click Go.
- Wait for the SQL file to be downloaded to your computer.
To download each database individually the process is a little different.
- From the main phpMyAdmin page select the first database you wish to export by clicking on the name of the database where it appears in the list of databases on the left-hand side of phpMyAdmin.
- Next, select Export from the top menu, and at the bottom of the export page click on Go.
Wait for the download to finish and then complete the same process for each database you wish to export.
If you aren’t sure which databases go with which WordPress website you can check by going into your website files in the htdocs directory, opening up wp-config.php for each WordPress site, and looking for the line that looks like this:
In this case, the database associated with this WordPress installation is called
Export each database you wish to keep and put it someplace you’ll be able to find it easily later on. Make sure you save it someplace far from the \xampp\ directory tree.
I want to keep all of my databases so I exported all of them at once and saved the entire SQL file in the same directory as my website files on my computer’s desktop.
Step 3: Uninstall the Old Version of XAMPP
First, before you try uninstalling XAMPP make sure you copied all of your website files and databases. Once you uninstall XAMPP anything you haven’t backed up will be lost. So take a second, go look at your website files and make sure you copied all of the files you wish to keep out of htdocs. Also, verify that you have all of the databases you wish to save. Once you’re certain you have saved a copy of everything you want to save, stop Apache and MySQL and exit the XAMPP control panel.
Now you’re ready to uninstall XAMPP.
There are three different XAMPP installation flavors:
- Automatic installer;
- Zip archive;
- 7zip archive.
The flavor you get if you use one of the download links at the XAMPP website is the installer version. The other versions are hosted at XAMPP’s SourceForge page, and you would only have one of those versions installed if you did so intentionally. So if you aren’t sure which version you have, you probably have the installer version.
If you do have the installer version you need to use the uninstall script to remove XAMPP. You’ll find the uninstaller at \xampp\uninstall.exe. If you are running either the Zip of 7zip version you can safely delete the entire \xampp\ directory without running an uninstall script.
If in doubt as to whether you have the installer or archive flavor, just check for the uninstaller. If you find it, run it.
When you run the uninstaller you may be asked whether you want to keep or delete the htdocs directory.
If you’ve followed my instructions so far, you don’t really need it. However, there’s certainly no harm in keeping it. So if you feel better saving it. Go ahead and do so.
Two backups are better than one, right?
If you select the option to keep your old htdocs folder intact and plan on installing the new version of XAMPP in the same location as the old installation, you will need to move the htdocs folder out of the \xampp\ directory. XAMPP can only be installed into an empty directory. Go ahead and move everything out of the old \xampp\ directory before attempting to install the new version of XAMPP.
Step 4: Install the New Version of XAMPP
Our tutorial on installing XAMPP walks through the installation process, so I won’t go over it in detail here. Head to the Apache Friends download page and select the version of XAMPP you want to install on your computer. I prefer the installer version you get when you download XAMPP directly from Apache Friends, but if you prefer the Zip or 7zip versions feel free to click on More Downloads and select the version you prefer. Download the version you want to install and get it set up on your computer.
Step 5: Adjust PHP Settings
The default PHP settings that ship with a new XAMPP installation are pretty restrictive, even more restrictive than an average shared server and strict enough to all but guarantee that you’ll exceed some sort of limitation while working with WordPress. Before going any further, I recommend making the following adjustments to the PHP settings:
max_execution_timeto 120 seconds;
Those settings can be adjusted by going to \xampp\php\php.ini, searching for the setting you wish to update, and increasing the existing value. If you’d like to take a look at detailed instructions on making those changes, check out our tutorial How to Troubleshoot and Fix Common XAMPP and WordPress Issues.
Step 6: Restore Your Website Files and Databases
Restoring your website files is easy. Simply copy the files and folders you previously backed up and paste them into the new \xampp\htdocs\ folder. Once they finish copying they won’t be ready to test just yet since you haven’t yet imported your databases.
To restore your website databases you’ll need to import the SQL file or files you exported from the original XAMPP installation.
Importing Multiple Databases Simultaneously
Uploading your databases all at once is pretty straightforward. Launch phpMyAdmin, select Import, choose the SQL file you exported previously from your last XAMPP installation, and once you have it selected, click Go.
If the file is large it may take a little while for it to be uploaded. Be patient.
There are a couple of things that can go wrong at this point:
- You may exceed the maximum time phpMyAdmin will allow to process an upload: 300 seconds. If that happens, you need to turn off the time limit on phpMyAdmin’s import process.
- If you accidentally included the phpmyadmin database in your SQL file you’ll see phpMyAdmin error 1050: “table already exists.” If that happens, you’ll need to tell phpMyAdmin to ignore multiple statement errors.
If you do run into an error, such as either of those listed above, that causes the import process to be aborted part of the way through, some of your databases will be imported while others are not. After fixing the setting that caused the error, but before you reattempt to import the databases, drop the databases that were imported. If you don’t, the data will be reimported when you reattempt the import process, and you will end up with duplicate records in all of your database tables.
Dropping databases is easy. Go to the phpMyAdmin homepage, click on Databases, select the checkboxes next to the databases you want to drop, and then click Drop. Just be careful not to drop any of the system databases such as phphmyadmin, information_schema, mysql, and performance_schema.
Importing Individual Databases
You’re less likely to run into errors importing databases individually which is exactly why I encouraged you to go this route earlier. However, the trick to making this process easy is to name the new databases exactly the same as they were named under your original XAMPP installation. If you don’t, you’ll have to go through and update the wp-config.php file for each site where the database name has changed.
The process of uploading your databases one at a time looks like this:
- Go the phpMyAdmin and click on New from the list on the left-hand side of the application.
- Create a new database being careful to use the exact same name as was used for the original database.
- Select the database you just created from the list in the left-hand panel in phpMyAdmin.
- Click on Import in the top menu, select the SQL file for the database you wish to import, and click Go.
- Once the import is complete, repeat the same process for the next database you wish to import until you’ve imported all of your databases.
The PHP setting adjustments I recommended will probably keep you from running into errors if you import databases individually. However, if you import any exceptionally large databases you could still run into errors. If you do run into errors, and they aren’t the errors I mentioned in the section about importing multiple databases, Google is your best bet for finding a quick solution. Post your problem and the solution you find in the comments below so that any fellow WPMU DEV readers who run into the same problems can benefit from your research.
Bask In Your New XAMPP Dev Powers!
Awesome. You’re done!
Once your databases import successfully it’s time to fire up XAMPP, start Apache and MySQL, and test your websites. Type in http://locahost/website_directory/ just as you have done in the past with your old XAMPP installation to access your websites. All of your old usernames and passwords will still work just fine.
Updating XAMPP is no easy process and you’re almost guaranteed to run into some sort of hiccup along the way. However, if you need access to updated components, such as the latest version of PHP, there’s really no way around going through the process.