So you’ve finished developing a WordPress website locally using your XAMPP development environment and you’re ready to push your work online. There’s just one problem: you don’t know how to get your website from your computer to a web server without breaking it, and breaking your site would really defeat the whole point of local development.
Fortunately, there are a couple of different effective ways you can go about migrating your website. Unfortunately, there is no silver bullet for WordPress website migration. If there were, all website creators and developers would use the same, simple, tried-and-true method. However, the lack of a single universally adopted method suggests that we’re still searching for a simple method that works perfectly every time.
All of this leads me to the conclusion that the only way to make migrating a website completely painless and stress-free is to hire someone else to do it! And even then, it’s only painless and stress-free as long as nothing goes wrong.
Since you’re still reading, I think I can safely assume you’ve decided to take care of this task yourself. While migrating a WordPress website from a local XAMPP-powered environment to a web server isn’t exactly easy, there are a few different ways to get the job done, and I’m sure you can handle all of them.
There are two ways WordPress websites are commonly migrated: manually and with a plugin. In this tutorial, I’ll go over both methods and then let you choose the method you like better.
Migrating a WordPress Website Manually
Migrating a WordPress website manually involves moving two major components:
Website files: Everything residing inside of the website’s root directory and subdirectories.
The database: The heart and soul of your website. A WordPress site without a database is like a laptop without a hard drive – loads of theoretical value, but ultimately useless.
Once you move your website’s files and database, you need to do two more things:
Tell the website files that they aren’t on localhost anymore, where they can find the database, and how to access to it.
Tell the database that it isn’t hosted on localhost anymore and give it the website’s new URL.
Let’s get started.
Export the Database from XAMPP
The first thing to do is to move your database. However, before you can do this, you need to know which database to move.
If you’re using the WPMU DEV Dashboard on your local site, the easiest way to identify the database is to go to WPMUM DEV > Support, select the System Info button, click on the MySQL tab, and look for the line that says Database.
If you aren’t using the dashboard plugin, find the directory that contains your local WordPress website. It will be in the xampp\htdocs directory. Find the directory that contains your website, open it, and locate the file named wp-config.php. Open this file with a text editor and look for the line that defines the database name. Here’s what it will look like:
In my case, the name of the database I’m moving is standardwp. You’ll see something different. Make a note of the database name. You’ll need it in just a minute
To get a copy of your local website’s database, the first thing to do is to start the XAMPP control panel. In the control panel, start Apache and MySQL, and then launch phpMyAdmin.
There are a few different ways to launch phpMyAdmin:
Click on Admin in the MySQL row in the XAMPP control panel;
Open a browser window and type http://localhost/phpmyadmin into the address bar;
Go to http://localhost and select phpMyAdmin from the menu at the top of the page.
Once you have phpMyAdmin open, look for the database name on the left-hand side of the application. Find the appropriate database name and select it by clicking on it. Next, select Export from the menu along the top of the application. Leave the Quick radio button selected unless you know there are database tables you don’t want to export, and click Go to download a copy of the database.
Create a New Database on the Server
Next, head to your hosting account and create a new database.
Depending on your host, you may have to use the MySQL Database tool rather than phpMyAdmin to create a new database. Either tool has the ability to create databases, but on shared servers it seems that many hosts disable this ability within phpMyAdmin.
In my case, I had to use the MySQL Database to create the database. To do this, I first selected the MySQL Database tool from my hosting account control panel.
Once I had accessed the tool, I created a new database and named it something I would recognize.
After creating the database I created a new user to use for this database.
Next, I assigned the user to the database.
If your hosting account already hosts several databases, you might be tempted to resuse one of the existing database users, but I would caution you against doing that. Using a different user and password for each database you create is a little annoying, but ensures that someone who gains access to one of your databases won’t have the keys to get into all of them.
Finally, after assigning the user to the database I was redirected to a page where I gave the user all privileges to modify the database.
When you reach this point, before switching away from this page, make a note of the database name, user, and password. You’ll need those details when connecting the database to the website files.
Import the Database to the Server
If you’re following along, you should now have an empty database on your hosting account and copy of your database tables ready to import. To import the database tables access your hosting account control panel and launch phpMyAdmin.
On the left-hand side of the application, find the database that you just created in the previous step. Once you find it, click on it to select it.
With your database selected, find the Import option in the menu along the top of the application. From the Import interface, look for the Choose File button. Use it to find and select the database tables you previously exported from your local XAMPP installation. Once you’ve selected the file containing the database tables, click Go to begin the import process.
If all goes according to plan, you’ll see a message letting you know that the import was successful. Once you see that message, you have successfully migrated a copy of your website database from XAMPP to the server that will host your website live on the internet.
Copy Website Files from Localhost to Your Hosting Account
Our database is ready and waiting for our website files. The most common way to move a large batch of website file is to use FTP. If you haven’t used FTP before our tutorial on using FTP with WordPress will get you started.
Open up your FTP client and access your hosting account. Next, within the FTP client, find the public_html directory on the web server and create a directory inside of it for your website files. Then, within your FTP client, find the directory that contains your website files in xampp\htdocs. Finally, select all of the contents of the local directory that contains your website files and drag them into the directory you just created on the web server.
For example, in my case the site I’m moving is contained in xampp\htdocs\standardwp. I created a directory for my website files on the server at public_html/xamppwpmigration. Next, I copied all of the content of standardwp into xamppwpmigration.
It may take a while for all of your website files to transfer to the server.
WordPress, We Aren’t in Kansas Anymore
Once the transfer has completed, you need to tell your website that it isn’t hosted on localhost anymore and also tell it where to find the appropriate database. You do both of these things by modifying wp-config.php.
To edit wp-config.php go back to your FTP client, connect to the server, locate the directory where you uploaded your website files, open the directory, and locate the file by name. Once you’ve located it, open it up so that you can edit it.
If you’re using Filezilla, open the contextual menu (right-click on PC or Ctrl + Click on a Mac) and select View/Edit to edit the file. Selecting that option will download the file and open it on your computer.
With the file open, scroll down until you see the line that defines the database name. On that line and the following lines, update the database name, username, and password to reflect the information that pertains to the database and user you just created.
At this point, you’ll want to tell your WordPress website files the URL where they’re now hosted. To do that, add the WP_HOME and WP_SITEURL definitions to the file as well.
For example, in my case the applicable database name is account_xamppwpmigration, the user is account_xamppwp, and the password is none of your business. I own the domain http://codetutorial.online but haven’t done anything with it. So I am using that domain to demonstrate the migration process for this tutorial. So I used that domain for both the site and home URL. In the end, this is what my wp-config.php file looked like.
After you’ve finished editing wp-config.php, save it, close it, and upload it back to the server overwriting the existing copy in the process. If you’re using Filezilla, you will be prompted to upload the file and delete the local copy after closing the file and going back to the FTP client.
One Possible Extra Step and Migration Success
Depending on the domain you are using for your website and how you’ve set it up, one additional step you may need to take is to tell your hosting account the directory that contains your website.
For example, in my case I accessed the Addon Domains tool within my hosting account control panel, selected the http://codetutorials.online domain, and changed the document root to public_html/xamppwpmigration – which you will recall is the directory where I uploaded my website’s files.
With your domain properly configured, your website files and database in place, and wp-config.php updated appropriately, you should now see your WordPress website live on the web.
At this point, you can log into your website admin dashboard using the same credentials you used when developing your website locally.
Find and Correct Database URLs
The last step is to run a search within your database to locate any references to the localhost URL and replace them with the URL of your live website. There are several different plugins you can use to do this. My personal favorite is the aptly-named Search & Replace plugin.
Pick a plugin, install it, activate it, and use it to locate instances of your local development URL and replace them with the correct URL for the live site.
Be very careful when going through this process. Including or omitting an extra forward slash is all that it takes to break a lot of links and images. If things go wrong, you can always use the copy of the database you just exported from your local website to repair the database.
Congratulations! You’ve now successfully moved your locally-developed website from a XAMPP-powered environment to a web server.
The good news is, you’re done! The bad news? It would’ve been a whole lot easier to just use a plugin.
Migrating from XAMPP to a Server the Easy Way
Migrating your WordPress website from XAMPP-powered localhost to a web server is easiest if you use a plugin. There are a quite a few that are up to the task, including WP Clone, WordPress Duplicator, and several others. However, since I already use Snapshot Pro to backup all of my websites, it makes the most sense to use it for this purpose as well.
Migrating a website from a XAMPP environment to a web server with Snapshot Pro is a simple five step process:
Install Snapshot Pro on both your local website and the brand new WordPress installation on your hosting account, a task that will be easier if you first install the WPMU DEV Dashboard from which you can automatically install Snapshot Pro.
Use Snapshot Pro to create a complete backup of your local WordPress websites, making sure to include all files and database tables.
Upload the backup to the WordPress site on your hosting account.
Use the backup and Snapshot Pro to restore a carbon-copy of your website.
If you’ve ever used Snapshot before, the process should be pretty painless. Even if you haven’t, you can probably get through it without many additional instructions. However, if you do want detailed instructions on using Snapshot Pro to migrate a site, take a look at our tutorial on How to Move a WordPress Site Without Hassle with Snapshot .
Edge Cases and Special Considerations
The methods described in this tutorial will cover most WordPress website migration situations. However, there are a few additional special circumstances that you should be aware of.
If you’re migrating a multisite installation manually, the process won’t change much. Your database will include a lot more tables, and wp-config.php will look a little different, but the basic process is the same. For detailed instructions, take a look at our previous tutorial on migrating multisite installations.
Migrating a multisite network with Snapshot Pro does include some additional steps.
First, get a brand new multisite-enabled WordPress installation set up on your hosting account. Then use Snapshot Pro to move the main site first, making sure to include all files and database tables. Then create a subsite for each subsite you plan to move, and use Snapshot to migrate each subsite one at a time until you’ve moved your entire network.
Migrating a Website That is Already Live on the Web
All of the steps so far assume that you are working with a brand new website. However, it may also be the case that you already have an older version of your website live on the web, and now you want to move your newly redesigned website to the server replacing your existing website.
There’s just one problem. How do you set up the new version of your website without experiencing any significant downtime?
Well, some people might tell you to plan your migration for 3 AM and assume a little downtime is inevitable, but I’m not one of those people. Instead, here are two ways you can migrate your site from a local XAMPP environment to the web without any downtime.
The first method is to migrate your website to a subdomain of your primary domain, and then to change the document root of your primary domain once you have set up and tested your site. Here are the steps to take to implement this method:
If your domain is http://example.com, use the Subdomains tool in your hosting account control panel to create a subdomain. For example, you may want to create http://staging.example.com.
Many hosts offer a tool you can use to password-protect specific directories. Create a directory for your website files and use this tool to set a password to restrict access to that directory.
When you migrate your site, set it up to be accessible using the subdomain you just created, access the site, and make sure everything is working properly.
Once you’re confident that your site looks and works exactly the way you want it to, remove the directory password.
Next, add the WP_HOME and WP_SITEURL definitions to wp-config.php tochange the site URL to your primary domain.
Next, adjust your primary domain’s root directory settings, selecting the directory that contains your updated website.
Once you’re certain that your website visitors are being served your updated website, go ahead and remove the directory and database that made up your old website and delete the staging site URL.
The second method is to enable multisite on your live WordPress website (after creating a complete backup) and to use Snapshot Pro to migrate your website to a private staging subsite of the multisite network. Then, once you have the private staging site working perfectly, use a multisite cloning plugin to clone your staging site back to your main site.
At this point, you have all the pieces you need to use a local environment powered by XAMPP for WordPress development.
Getting comfortable with this process means you never again have to cringe in dread when installing a plugin or activating a theme. Try out plugins and themes locally before they ever have the opportunity to break your live website. Working in this way may take a little more effort and time than making changes directly to your live site, but the risk of locking down a live website is enough to justify taking the time to master local WordPress development with XAMPP.
Have you ever migrated a website from a XAMPP environment to a web server? How did it go? What wisdom did you gain through the process that you can share with us?