How to Move WordPress From Local Server to Live Site

How to Move WordPress From Local Server to Live Site

It’s common practice for WordPress developers to create websites on a localhost, which is a local server hosted on their personal computer or laptop. Developing websites locally has a lot of advantages over a live server, but once site development is complete, it needs to be moved to a live website and made publicly accessible.

If you’re relatively new to website development, moving a WordPress website from localhost to a live website will require a bit of extra learning. The process can be quite involved and take some time if you do it manually.

While a plugin is the easiest solution for migration, you may run into some issues if your site is particularly large or if there are any conflicts between the local and live environments. So, in some cases, a manual migration is still the best option.

Five reasons to develop your WordPress site on a localhost

If migrating a WordPress website from a localhost is time consuming and prone to error, why shouldn’t you just develop on a live server from the start?

Here are the advantages of developing on localhost:

  1. It’s faster. Developing locally is fast as there’s no need to push files to the live server. Instead, you can work directly with the files you need.
  2. It’s safer. You can easily experiment or carry out updates locally to check for any errors or incompatibilities. Because you aren’t using an internet connection to develop, you’ll be safe from hacking attempts due to any vulnerabilities in plugins or themes you may be using.
  3. You don’t need to be connected to the internet. Taking a flight? Working from a location with slow or unreliable internet? Local development is perfect in this context.
  4. It saves server resources. Anything you do on your local server won’t affect your live server.
  5. It reduces cost. Depending on the type of website you’re building, development could take weeks or months. If you build your site on a live server, you (or your client) will be paying for hosting costs that entire time. Most local development environments are free to use, which can save hundreds or thousands of dollars over the course of development.

Why Move WordPress From a Local Server to a Live Site?

Building your WordPress blog on a local server is a safe way to test changes on your website without affecting visitors.

When you’re finished perfecting your website, the next step is to move to from your local server to a live site.

Let’s show you two different ways you can move your site from a local server to a live site.

The first method uses a WordPress migration plugin and is recommended for beginners.

In the second method, we will show you how to manually move WordPress from a local server to a live site.

You can choose the method that works best for you:

  • Method 1. Move WordPress from local server to live site using a plugin
  • Method 2. Manually move WordPress from local server to live site

Before You Migrate Your WordPress Site

In order for you to migrate WordPress from a local server to live server, you need to have a few things in place.

First, we’re assuming that you have a WordPress site running on a local server (also called localhost) on your computer, and you have full access to it.

Next, you’ll need to have a domain name and web hosting.

To make your decision easier, we recommend using Bhosting. They’re an officially recommended WordPress hosting company.

Method 1. Transfer WordPress from Local Server to Live Site Using a Migration Plugin

This method is easier and recommended for beginners. We’ll be using a WordPress migration plugin to move WordPress from localhost to a live site.

Step 1. Install and Setup the Duplicator Plugin

First, you need to do is install and activate the Duplicator plugin on your local site. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to go to Duplicator » Packages page and click on the ‘Create New’ button.

How to Move WordPress From Local Server to Live Site

This brings you to a screen where you can give your backup a name.

Then, click the ‘Next’ button.

How to Move WordPress From Local Server to Live Site

Duplicator will now run some tests to see if everything is in order.

If all items are marked ‘Good’, then click on the ‘Build’ button.

How to Move WordPress From Local Server to Live Site

This process may take a few minutes depending on the size of your website. You need to leave this tab open until the process is complete.

Once finished, you’ll see download options for ‘Installer’ and ‘Archive’ packages. You need to click on the ‘One-Click Download’ link to download both files to your computer.

How to Move WordPress From Local Server to Live Site

The ‘Archive’ file is a complete copy of your WordPress site. It includes all WordPress core files as well as your images, uploads, themes, plugins, and a backup of your WordPress database.

The ‘Installer’ file is a script that will automate the entire migration process by upacking the archive file containing your website.

Step 2. Create a Database for Your Live WordPress Website

Before you can run the installer or upload the WordPress website from localhost to your hosting server, you need to create a MySQL database for your new live website.

If you have already created a MySQL database, then you can skip this step.

To create a database you need to visit your hosting account’s cPanel dashboard. Then, locate the ‘Databases’ section and click on the ‘MySQL Database Wizard’ icon.

How to Move WordPress From Local Server to Live Site

On the next screen, there’s a field to create a new database.

Simply provide a name for your database and click on the ‘Create Database’ button.

How to Move WordPress From Local Server to Live Site

cPanel will now create a new database for you.

After that, you need enter a username and password for your new user, and then click the ‘Create User’ button.

How to Move WordPress From Local Server to Live Site

Next, you need to add the user you just created to the database.

First, click the ‘All Privileges’ checkbox.

How to Move WordPress From Local Server to Live Site

Then, scroll down and click the ‘Make Changes’ button to save your changes.

Your database is now ready to be used with your WordPress site. Make sure to note down the database name, username, and password. You’ll need this information in the next step.

Step 3. Upload Files from Local Server to Live WordPress Website

Now, you need to upload the archive and installer files from your local site to your hosting account.

First, connect to your live site using an FTP client. Once connected, make sure that the root directory of your website is completely empty.

Normally, the root directory is the /home/public_html/ folder.

Some WordPress hosting companies automatically install WordPress when you sign up. If you have WordPress files there, then you need to delete them.

After that, you can upload the archive.zip and installer.php files from Duplicator to your empty root directory.

How to Move WordPress From Local Server to Live Site

Step 4. Running The Migration Script

After you have uploaded the migration files, you need to visit the following URL in your browser:

http://example.com/installer.php

Don’t forget to replace ‘example.com’ with your own domain name.

This will launch the Duplicator migration wizard.

The installer will run a few tests and will initialize the script.

How to Move WordPress From Local Server to Live Site

Under the Setup section, you will be asked to enter your MySQL host, database name, username, and password.

Your host will likely be localhost. After that, you will enter the details of the database you created in the earlier step.

Then, click on the ‘Validate’ button to make sure the details you entered are correct.

How to Move WordPress From Local Server to Live Site

After that, click on the ‘Next’ button to continue.

Duplicator will now import your WordPress database backup from the archive into your new database.

It will also update URLs pointing to local site to your new live site.

You can now click on the ‘Admin Login’ button to enter the WordPress admin area of your live site.

How to Move WordPress From Local Server to Live Site

Once you log in to your live site, Duplicator will automatically clean up the installation files.

That’s all, you have successfully moved WordPress from local server to your live site.

Method 2. Manually Transfer WordPress from Local Server to Live Site

In this method, we will show you how to manually move WordPress from local server to your live site. It will come in handy if the first method doesn’t work or you prefer to do it manually.

Step 1. Export Local WordPress Database

The first thing you need to do is export your local WordPress database. We’ll be using phpMyAdmin to do that.

If you are unfamiliar with it, then you might want to take a look at our guide to WordPress database management using phpMyAdmin.

Simply go to http://localhost/phpmyadmin/ and click on your WordPress database. Next, click on the ‘Export’ button from the top menu bar.

How to Move WordPress From Local Server to Live Site

In the ‘Export method:’ option, you can choose ‘Quick’ or ‘Custom’. Custom will provide you with more options to export your database.

But, we recommend choosing ‘Quick’, and then click the ‘Go’ button to download your database.

How to Move WordPress From Local Server to Live Site

Step 2. Upload WordPress Files to Live Site

Now, we’ll need to move all your website files to the live site.

To get started, go ahead and open your FTP client and connect to your web hosting account.

Once you’re connected to your live site, make sure you upload the files in the right directory. For example, if you want the site to be hosted on ‘yoursite.com’, then you would want to upload all the files in your public_html directory.

Now select your local WordPress files and upload them to your live server.

How to Move WordPress From Local Server to Live Site

Step 3. Create a MySQL Database on Your Live Site

While your FTP client is uploading your WordPress files, you can start importing your database to the live server.

Most WordPress hosting providers offer cPanel to manage your hosting account, so we’ll show you how to create a database using cPanel.

First, you need to log in to your cPanel dashboard and click on the ‘MySQL Database Wizard’ icon which can be found in the ‘Databases’ section.

How to Move WordPress From Local Server to Live Site

On the next screen, you can create a new database.

You need to provide a name for your database, then click ‘Create Database’.

How to Move WordPress From Local Server to Live Site

cPanel will now automatically create a new database for you.

Next, you need enter a username and password for your new user, and then click ‘Create User’.

How to Move WordPress From Local Server to Live Site

After that, you need to add the user you just created to the database.

First, check the ‘All Privileges’ checkbox.

How to Move WordPress From Local Server to Live Site

Then, scroll down and click ‘Make Changes’ to save your changes.

You’ve successfully created a new database for your live WordPress site.

Step 4: Import WordPress Database on Live Site

The next step in the process is to import your WordPress database.

Go to your cPanel dashboard, scroll down to the ‘Databases’ section and click on ‘phpMyAdmin’.

How to Move WordPress From Local Server to Live Site

This will take you to phpMyAdmin where you want to click on the database you just created above. PhpMyAdmin will show your new database with no tables.

Next, click on the ‘Import’ tab in the top menu. On the import page, click on ‘Choose File’ button and then select the database file from your local site you saved in the first step.

How to Move WordPress From Local Server to Live Site

After that, click the ‘Go’ button at the bottom of the page. Your database will automatically be imported to phpMyadmin.

Step 5: Change the Site URL

Now, you need to change the site URL in your database, so that it will connect with your live WordPress site.

In phpMyAdmin, look for the wp_options table in your database that you just imported above.

If you changed your database prefix, then instead of wp_options it might be {new_prefix}_options.

Next, click on the ‘Browse’ button next to wp_options. Or, click the link in the sidebar to open up the page that has a list of fields within the wp_options table.

How to Move WordPress From Local Server to Live Site

Then, in the options_name column, you need to look for the siteurl option.

Then, click the ‘Edit’ icon.

How to Move WordPress From Local Server to Live Site

This brings up a window where you can edit the field.

In the input box for option_value, you’ll see the URL of your local install which will be something like http://localhost/test.

You need to insert your new site URL in this field, for example https://www.bhosting.ng.

Then, you can save the field by clicking the ‘Go’ button.

How to Move WordPress From Local Server to Live Site

Next, you need to follow the same steps as above for the home option name. The wp_options menu can be a few pages long, usually the home option will be on the second page.

Then, update the home URL, so it’s the same as your live site URL.

Step 6: Setup Your Live Site

Now that you’ve imported the database and uploaded your content, it’s time to configure WordPress.

At this time, your site should be showing an ‘Error establishing a database connection‘ error.

To fix this, connect to your website using an FTP client and open up the wp-config.php file.

You’ll be looking for the following lines of code:

1
2
3
4
5
6
7
8
9
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

You will need to provide the database name, username and password you created earlier.

Next, save the wp-config.php file and upload it back to your WordPress hosting server.

Now, when you visit your website, it should be live.

After that, you need to login to your WordPress admin panel and go to Settings » General. Then, without changing anything, scroll to the bottom and click the ‘Save Changes’ button.

How to Move WordPress From Local Server to Live Site

This will make sure that your site URL is corrected anywhere else that it needs to be.

Once you’ve done that, go to Settings » Permalinks, then scroll down and click ‘Save Changes’ to ensure that all post links are working fine.

How to Move WordPress From Local Server to Live Site

Step 7: Fix Images and Broken Links by Updating Paths

Whenever you’re moving a WordPress site from one domain to another, or from a local server to a live site, you’ll face broken links and missing images.

A simple way to update the URLs is by using the following SQL query.

1
UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.yourlivesite.com/');

Simply go to phpMyAdmin, click on your database, and then click on ‘SQL’ from top menu and add the query above.

Make sure you change it to your own local site and live site URLs, and click the ‘Go’ button.

How to Move WordPress From Local Server to Live Site

That’s it, you have now successfully migrated WordPress from your local server to a live site.

Hopefully, now your live website is up and running smoothly.

Leave a Reply

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