How to move wordpress website from localhost to live server

0
348

It is best way to develop wordpress website in your local server and after complete move it into the live server.  You can develop the site in live server but please try to avoid developing in live server. Because in starting days I had the habit of developing the site in live server.  One day my server was crashed and all data were lost, I didn’t have backup for developing website. So I was suffered and rebuild the site. Also server will take high bandwidth when you are working on it. So have the habit of developing the website in local server.

Now I assume you have completed the wordpress website development in localhost and ready to move live server. Before that I want to confirm you have the hosting details (access to file manager and database)

There are two methods available to move wordpress website from localhost to live server. Are you ready to go?

Method 1: Export content using built-in wordpress tools

In this method you are going to export the content (posts, pages, comments etc,) using the wordpress export tool. The exported file will be in the XML format.

wordpress export

To export the content you need to go to TOOLS -> EXPORT in the admin left menu section. There you can select which content need to export whether post, page or comments. You can also export all content. Please see the above the image for reference.

You have the content of the website in your hand. Now you are going to import the content in live site. Before that install and activate your developed/customized theme in live. Then go to TOOLS ->IMPORT and install the wordpress importer. Now it installed then browses your XML file and import it. See the below image for reference.

Wordpress import

Now your content is moved to live successfully. But in this method you need to rebuild your menus and widget. This is one of the methods to move your content to live quickly. But I do not recommend this method to move whole site to live, because you have to work once again in the site.

Method 2: Moving all files and DB from localhost to live server.

This is the efficient and easily doable method. In this method you only need to do six steps and it will not take much time.

  1. Export the database SQL file from localhost
  2. Create new database in live server
  3. Import the SQL file into new database
  4. Move all files from local to live server
  5. Edit the wp-config.php file
  6. Modify permalinks

1. Export the database SQL file from localhost:

In your localhost go to phpmyadmin and select your wordpress database. In the top menu you can see Export option, click on that. The below showing screen will open, in that you need to select SQL format and press the Go button. Your SQL file is now exported.

DB export

2. Create new database in live server:

Login into your hosting account, in the control panel you will MySQL Database option. Click on the MySQL Database and there you can create your new Database and their user.  Please see blow image for reference (it may be vary depend upon the control panel)

create database

3. Import the SQL file into new database:

Like you export the database from local server you can import it into the live server. Go to the live phpmyadmin and select your database which you are created.  In the top menu you can see the import option click on that. The below showing screen will open, in that you need to browser exported SQL file and press the Go button. Your SQL file is now imported.

import database

In the imported file you need to change the site URL, because in local server the URL should be like http://localhost/sitename. You need to change to your live URL.

changesite name

4. Move all files from local to live server:

Your database is ready in your live server. Now it is the time to move all files to live server.  You can do it using FTP (Filezilla or Fireftp) or through File Manager (It is the easiest and best way).  Move it wherever you want like in root (public_html or www) or in sub folder.

5. Edit the wp-config.php file:

After moving the all file from local to live, you have to edit the wp-config.php file and change the old database connection with new database connection.

define(‘DB_NAME’, ‘Database name’);

define(‘DB_USER’, ‘Database username’);

define(‘DB_PASSWORD’, ‘Database Password’);

define(‘DB_HOST’, ‘localhost’);

6. Modify the Permalinks:

After completing the all above steps, you can access the admin page. So login into you admin page and change your permalinks by going to Setting -> Permalinks. Please see the below image for reference.

permalinks

Wow you finished it. Now you can able to access your live new website. Please take regular backup of your website. If you have any feedback or question please drop it in our comment section. If you find this post useful please share it with your tech friends.

LEAVE A REPLY