How to Take Your Local WordPress Site Live

How to Move WordPress from Localhost to Server

Today, I’ll share how to move WordPress from localhost to a live server so you can launch your website with ease.

Before You Begin

Prior to starting the process of moving WordPress from localhost to server, there are a few things you need:

  1. A WordPress site on a local development server with full access to it.
  2. A domain and hosting package where you can upload your website.
  3. An FTP (File Transfer Protocol) client.

How to Move WordPress from Localhost to Server

To manually move WordPress from localhost to server you will:

  1. Transfer the WordPress database and files.
  2. Make sure all WordPress URLs and media links are updated.

Below is a breakdown of these steps in detail.

Export Database from Your Local Server

The database of your WordPress site houses all your users, posts and taxonomies which are all must-keeps if you have input content on your site already.

To move the database, open your local server application’s phpMyAdmin and select the database you want to export in the left-hand sidebar.

Select the database to export from phpMyAdmin’s sidebar list of databases.

Select the Export tab from the navigation bar at the top of the screen.

phpMyAdmin can export the database in a variety of configurations.

The two export methods are Quick, which displays minimal export options, and Custom, which displays all the export options.

We recommend choosing Quick. Then, click Go.

Upload Files to the Live Server

While your database has all of your post content, your files contain your themes, plugins and core WordPress files.

To move your files from your local server to a web server, use an FTP client to connect to your remote hosting server.

Every web host’s setup is different so most hosting companies provide tutorials on uploading files to their servers using an FTP client. If you get stuck, check your web host’s support area for further instructions.

Cyberduck is one of the many free FTP clients available.

Make sure your FTP client is connected to the correct folder on both your local computer and remote web host. The latter is typically the public_html folder, but could be a subdirectory within public_html depending on how you have configured your server space.

Check with your host if you unsure what folder you should use on your server.

Then, upload all of your local WordPress files to the live server.

Create a Database on the Live Server

Most hosts use cPanel to manage their databases. If your host uses something else, check with them for details on creating a database.

Log in to your hosting account’s cPanel dashboard and go to the Database section.

Select the MySQL Databases icon.

cPanel allows easy access to your hosting account’s MySQL Databases.

Next, enter a name for your database in the Create a New Database > New Database field.

Click the Create Database button.

Database names should be relevant, lowercase and contain no spaces.

Now, you can either create a new user and add it to the database or add an existing user to the database.

After doing so, you’ll be asked to select what privileges this user can have. In this case, all privileges should be granted.


Adding a user to a database via cPanel is a breeze.

Check All Privileges and click the Make Changes button.

Import Database to Live Server

Back in the cPanel dashboard, go to the Database section again and this time click on phpMyAdmin.

Import your local database file into the live database with phpMyAdmin.

Select the Import tab at the top of the screen.

Click the Choose File button, then locate and pick the local database file you created earlier.

Click Go at the bottom of the page. PhpMyAdmin will now upload your database.

Change Your Site URL

If the actual website address doesn’t match the site URL in the database, WordPress won’t function properly.

The URL of your local WordPress site was probably something like this: http://localhost/wp-site-folder. However, the live WordPress site will be using your purchased domain URL which would look something like this: https://www.my-wp-site.com.

You can change the site URL in your newly imported database by updating the database tables.

In phpMyAdmin, select your database from the sidebar on the left and go to the Structure tab.

In the tables that appear, locate the wp_options table and select Browse.

 
Under Structure, you can edit the site URLs in the wp_options table.

In the Browse tab, you should see another table that houses the Options data. The options you’ll need to edit are siteurl and home.

The siteurl is the domain address your website uses and home is the address visitors are redirected to when they click a home link on your WordPress website.

In the wp_options table, you’ll update the values for siteurl and home.

Select Edit for siteurl.

On the next page, update the option_value field to be the live website URL. Then, click Go to save your changes.

Repeat these steps for the home option. Typically, you should use the same URL for both.

Configuring WordPress

Now that all your database and files are in place, you can set up WordPress.

If you visit your live URL at this stage, your site will display an error regarding your database connection because your wp-config.php file isn’t using the new database credentials.

To solve this error, connect to your live website with the FTP client and open your wp-config.php file.

Replace the database name, username and password credentials with the ones you created in the cPanel earlier.

For the hostname, you can leave it as localhost or replace it with the server IP address.

In your code editor, change the credentials in your wp-config.php file to match your live server.

It may be important to note that you should make a copy of your old values in case you need to revert back to them for any reason.

Save the wp-config.php file and upload it back to the server. Check your live website again and the error should be gone.

URL Permanence

To ensure that the site URL is corrected where ever it’s necessary, log into your WordPress dashboard and go to Settings > General.

Without changing anything, scroll to the bottom of the page and click Save.

Lastly, go to Settings > Permalinks and click Save Changes to integrate the URL changes with the rest of WordPress.

Fix Images and Broken Links

Often when you’re trying to move WordPress from localhost to server, links and images can end up broken or missing.

This simple SQL query can help you solve the issue when it’s run in your web server’s phpMyAdmin:


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


To run the query, access phpMyAdmin from your cPanel, select your WordPress database and go to the SQL tab at the top of the page.

Paste the query, update the URLs to match your setup, then click Go.

Shifting into Automatic

If you don’t love the manual nature of the process to move WordPress from localhost to server, here are a couple plugins that will free up your time and any possible headaches.

All-in-One WP Migration

All-in-One WP Migration is an extremely popular plugin with over 1 million installations and counting. The plugin help with transferring WordPress websites from one point to another with no need for any sort of technical knowledge.

The plugin is compatible with all PHP hosting providers, has unlimited find and replace operation in the export process, and can easily bypass hosting file size restrictions.

Duplicator

Duplicator is a migration plugin that gives WordPress users the ability to migrate, copy, move or clone a site from one location to another.

It also serves as a simple backup plugin. Duplicator creates packages that bundle together all your WordPress files and database into ZIP format for easy transportation.

With this particular plugin, it helps to have some technical knowledge and understanding of the migration process.

Mission Completed

Taking a site live is an exciting culmination of all your hard work. While it may initially feel complicated to move WordPress from localhost to server, the steps above should help make the process a snap.

Do you prefer to manually move WordPress from localhost to server or do you prefer using a plugin? Were you able to successfully migrate your site? Did you run into any issues during the migration process? Let us know in the comments below.

FURTHER READING