Migrating your WordPress Site from Local Server to Live Server
This guide is developed to help web designers who have been developing their sites locally and are wondering how they are going to migrate their project from their local server to a live server. Here we are going to see two different ways to do this: basically, the easy way, using a free plug-in called Duplicator and the ‘I wish I was dead right now’ way, using an SFTP client.
We are just kidding, there is only a hard way for the weak ones of spirit and heart, cheer up! If you have come to the point you have finished a site on your local server and is ready to migrate it to a live host, you are no beginner and you are familiar with FTP clients. The process via SFTP might be much slower and meticulous, but it is very important for any web designer to know how to work with it when uploading a site to a live server.
Likewise, we are not going to talk about how to install WordPress on your machine and set up virtual server into your computer, the basic steps for anyone to develop sites offline, locally. If you are checking this guide interested in developing sites in your own machine before you upload them to your live server, you should check first how to create this virtual ambient into your computer. We cannot also cover here these topics or we will end up writing a book instead of a post.
Preparing for the Migration
To perform the migration, especially via manual method, you have to do a proper back up of all your local files and export your data base. The latter you should do through the phpMyAdmin ambient or the software you used to create your virtual server – probably WAMP, XAMPP, or the MAMP one if you are a Mac user.
Since you are developing and running your site in a virtual local server, these methods will be essential to create a back up with the correct paths and permissions, for example. This is also important to avoid any kind of problems that might happen migrating with the plug-in or manually. You know that when something can go wrong, it will.
Packing your Local Site
We assume at this point that you surely already has your own host server and domain. Meanwhile, we are going to “pack” things to leave your computer to move in to your live server, so let’s open the WordPress on your local host and look for the Duplicator plug-in and install it.
Note that this might be confusing, but you have to install the Duplicator in the local host for now and not in the Live host.
- Go to your Admin area in the LOCAL WordPress site
- Click on Plugins and then Add New
- Look for Duplicator, created by LifeinTheGrid, install it and activate it.
- A new tab will show up in your Dashboard side menu, click on it and then click on Packages
- Click on Create a New Package and fill in the info requested (name of the package, description, etc)
- You don’t have to change any of the other settings. The package is set to be created as a .zip file.
- Click on Next. The plug-in will run a scan to check if everything is fine with your data base and settings in general. If everything is fine, you will be able to click on ‘Build’
- It might take some minutes to pack it all up, but after a while, it will be ready and a Complete pop up will show.
- Now, click on Installer, to download the php file that will migrate your package to the live server, and of course, click on Archive to download the package. Once the download of both files is complete, we will move to the uploading process to the live server.
Uploading to Live Server
What we have to do now, first, is upload these files to your “public_html” folder in your server (or www in FTP clients). You can do this either via cPanel or FTP client
- In the cPanel, go to File Manager an then Upload to select the files
- In your FTP client, drag and drop them into your www folder
Next step is to create a Data Base for these files inside your live server. If you don’t remember the steps you can check out our post about Installing WordPress where you will get directions to create the MySQL Database through the cPanel. Now, let’s get this site working.
- Enter your live site address in your browser and let’s access it. You will see a ‘index’ alike page where you will be able to click the installer.php file. Click on it!
- You will see the Duplicator interface there, where you have to configure now the data base we created a while ago. Fill in the name of the database, user name and password and click on Next
Duplicator will set up your site and this might take a few minutes or seconds depending how big is your site. Once everything is ready, you get a Sucess screen. There you have options to test your site, to save Permalinks, remove the installer files and other complementary information.
Is recommended you delete the package file because it is useless now and will be just taking up space in your server. Everything must be working well and we are done with the migration!
Migrating via SFTP
As we said before, there is no hard way to migrate your files, and while Duplicator will be much faster because it will require less clicks, checks and edits, the upload via SFTP is not really a difficult task. Let’s get started and you will see we will soon be already finished.
- Once your SFTP client is connected to your live server, open the “public_html” or “www” folder
- Now, grab all the files of your local server folder and drop them there
While you wait for the upload to be be completed, you can already set the new data base for the site similarly like we did with the Duplicator. Though, instead of generating one with the files already uploaded, we will make use of our backup data base we did in the beginning.
- Go to your cPanel and get to the MySQL Data base to create a new one
- When you are finished, get to the phpMyAdmin ambient
- Click on the tab ‘Import’ and select the back up DB we did
- Click OK and we already have our data base also appropriately uploaded
Setting up the Site
When all files are already upload via SFTP client, we will have to make some adjustments so your site will answer as a WEB site and not a LOCAL site. While you were developing your site, you were working with a specific data base that has different name, user and password than the one we created for the live site, as well as you configured your site to answer by a local path.
Now we have to change this data, inform the actual and current info of the data base and configure WordPress to address the site via your actual site address in the web.
- Open the “wp-config.php” file and change the information for the database entered there. Enter the new name, user name and password for the data base we just created here in the live server.
- Save and close the file.
- Get back to the phpMyAdmin ambient
- In the Data base tab, look for the ‘wp_options’ table and click on ‘Browse’ to see all settings allocated for the WordPress site
- Now, look for the ‘siteurl’ feature, you will easily find it following the field ‘options_name’
- Once you have found it, you will see its “value” is the local path. Click on Edit and enter your actual site adress, including the http://
- Do the same with the feature ‘home’, which is the name of the option and you will similarly find looking through the ‘options_name’.
- When you are finished editing, get back to the phpMyAdmin and set a rule to replace the old local path with the new site address This will fix all broken links and missing images. We will do this using the SQL query.
- Click on your Data base and then click on the SQL tab
- There, type the following code many users apply to fix broken link:
UPDATE wp_posts SET post_content = REPLACE(post_content, ‘yourlocalhostpath/folderofyoursite/’, ‘www.youractualsiteadress.com/’);
And that’s it buddies, your site should be running live in your server right now. Note that this old school method requires this manual checking and editing, so if you get too many errors or is having a hard time to make it work, use Duplicator because it will at least have a library of errors to show whenever any problem show up during the migration, so you will know better what to fix and how to fix.