Move your WordPress site from local server to the live site

Category: Intermediate

We already have a post on how to install WordPress on your local Windows computer using WAMP. After installing WordPress in your local computer and changing the look to something you feel good about, you would need to transfer it to your main server to make the site live. Here is a step by step guide on how to do it.

It would also come in handy when you shift your site from staging ( to live( as the processes involved are the same.

There are many WordPress plugins which help you in this process, but in this post, we will show you how to do it manually. Before we start, you need to make sure you web host has support for PHP as well as MySQL installed. Also, you need to have access to the database and files on your local server.

Start the next steps after you have set up your site in localhost and you are happy about its looks and content.

1. Export data:

The first part, naturally, is to export the data from your local server.

To export the WordPress database, first you need to login to PhpMyAdmin to export the data. We also have a detailed post on how to use PhpMyAdmin to manage your WordPress database.

After logging in and selecting your database from the list, you need to select “Export” from the tabs at the top.

Select the option of ‘Quick’ export method which exports all data off the database. In case you select ‘Custom’, you would be able to select the tables for which you want to backup the data.

You will find that a text file with a .sql extension would be available for download. That file contains the data from the WordPress database.

Next, you need to upload your files to the remote server too. Since a remote server’s file manager like cPanel allows one file upload at a time, rather than uploading single files, you need to zip your WordPress directory and upload the zipped file to your server.

2. Importing the data on the remote server:

In most cases, your server would have PhpMyAdmin installed by default. In case you have terminal access, you can install a copy of PhpMyAdmin by following the instructions on their download page, or cloning their Github repository.

Once logged into PhpMyAdmin, create a new database by the same name that was present in your local server. Click the ‘Import’ button right next to ‘Export’. Select the SQL file to upload and click Go (let the default options remain as they are).

Uploading your files is a bit more complicated though. You might be provided with a file transfer service by your webhost or you can use a FTP client and connect to your site.

Upload all the files to your public_html directory. If you are uploading a zipped file, you must unzip it and delete the zipped file later.

Caution: If you leave the zipped file in your public_html directory, anyone would be able to download it and get your site’s sensitive information. That would mean your site would not remain secure anymore.

If your WordPress files are inside a directory, for instance ‘blog’, under public_html, that means you can access your WordPress going to In case you want to point to your blog, you need to move your WordPress files up one directory. In case you want to point to your blog, you need to set it up as a sub-domain first.

After the upload, you need to edit the wp-config.php file to make sure everything is synced with the server. Note that the username and password will generally be the same as the ones you use to login to your FTP server, unless you installed MySQL separately and set a different username-password combination.

In case you are not sure or you are having trouble with the connection, you can also create a new user in PhpMyAdmin. After logging in, go to the Users tab at the top and click on ‘Add user’.

You can either create a new database or grant access to all existing databases. Remember to give proper privileges to the user too.

3. Changing the Site URL:

After copying the files and importing the database, you need to change the site URL in WordPress to render all links properly. Otherwise, you would find that each and every URL would point to your local server.

To do so, you need to first open the table wp_options in PhpMyAdmin (I am assuming you kept the table prefix as wp_ which is by default).

Edit the entry corresponding to the siteurl and change it to the directory in which your blog is (as explained above)- either, or

Usually this table is quite long and can run a few pages, so make sure you update the home url to be the same as your siteurl too.

4. Finishing touches:

You can now open your WordPress home page in your browser to make sure everything is working. In case you are greeted with a “Error establishing database connection” message, you need to open wp-config.php and double check that your data in it is right.

Now, evidently, you must have used http://localhost/ as a link to your internal posts and images- all those links would be broken in your new site. To correct that the worst possible way is to manually change the links in the post. That could take hours, if not days.

Thankfully, you can do it using a simple SQL query. To run the query, you can select SQL from the tabs in PhpMyAdmin, paste in the following SQL query and select Go:
UPDATE wp_posts SET post_content = REPLACE(post_content, ‘localhost/wordpress’, ‘’);

Doing that would dynamically change all your internal links to posts and images in your posts.

5. Securing your site:

Getting a call from a friend saying your site is down and hacked is never a good thing. To avoid such situations, it is good to add an additional layer of security to your WordPress site.

To do so, place a blank index.php file in wp_content, wp_content/themes and wp_content/plugins folders, with the following line in them.

<?php //This is a blank file for security ?>

That’s it. If you have followed all these steps, you should have your site up and running by now.

Author Bio

Shaumik Daityari

Shaumik is an optimist, but one who carries an umbrella. An undergrad at IIT Roorkee, he loves writing, when he's not busy creating some awesome stuff. Find him on and Twitter.

Leave a reply

Appointment Booking Plugin for Wordpress