If you want to move from localhost to live site you need to have a few things ready with you.
- A locally developed/running WordPress site.
- Have full access to the site.
- FTP software.
- Text Editor, (Notepad ++, Sublime text or any other text editor you want.)
- A hosting plan and a Domain.
That is all we need to move our site from localhost to live server.
If you already have FTP software installed then we are good to go, if not install the FTP software on your system.
If you don’t know which FTP software to download, Click here to download FileZilla. FileZilla is easy to use and works well for transferring a large number of the file. Installing the FileZilla should be easy for you, So, install it.
I assume you that you have installed the FileZilla and you are ready to rock.
Step 1: Check the Website
Run the website once again on your localhost and navigate to every single pages and category to check everything is working fine and nothing is wrong. Check for errors and fix them before we migrate to live site.
Check the username and password once again check your dashboard is working fine and there aren’t any error on PHP codes. Try installing the plugins and uninstalling it on your site. Try posting the articles and sort it according to categories and see if everything is in place properly. Also, don’t forget to check if the site is allowed to indexed by search engine.
To change this setting > On your dashboard navigate to Settings > Reading > scroll down> and make sure the Discourage search engines from indexing this site is not checked.
Now, we are all set.
Step 2: Export Database from Localhost.
Export the database from localhost.
The proper way to export database,
- Click on the export tab on your desired database.
- On export method “Check” “custom-display all possible options”.
- After that select the format of the database as SQL.
- And under the table heading click on “Select all” and “click on Structure and Data”
- Give a name to your database.
- Choose the “
- Let all the settings be the default and scroll down to the bottom and hit “GO”
Now, your database has been downloaded. We need to edit a few things in our exported database before we move forward.
Now, open your “.sql” database in a text editor. Windows or Mac may not recognize the .sql format.
So, to open the database, right click on database> open with a> text editor of your choice, For me, it’s sublime text.
We need to change the URL (http://localhost/wordpress) that is set on our database to the live site URL (http://example.com).
How to change the URL on the database.
Use this trick for Sublime Text.
Ctrl+F > http://localhost/(your site name) in localhost > find all > http://example.com
You may be wondering why am I not using https:// that is because https:// is an SSL protocol which you have to enable from your hosting package after migrating to live site. If you move your site to live site with https:// your site is likely to crash or not function well.
If you are using plugins to develop some part of the site, make sure to change the values as instructed above.
Our database is ready to work on a live site.
Step 3: Creating a database on the live server and import.
We are all set now, we just need to create a database on our domain server.
To create a database:
Login to your domain cpanel > On the dashboard >Click My SQL database> create New > remember to use the same name as on the localhost database.
We have successfully created a database, we need to create a database user so that the database can be accessed by the WordPress site on a live server.
To create a user for a database:
On the same page where you created a database, you will find an Add New User.
Create a username and a password and remember it, as we will need these in the next step.
After all this process,
Head back to cpanel and find phpmyadmin to import the database.
Click on the database you created above, make sure you use the database you created above or else your website may not work.
On the database you selected above, click on import on the top > choose file >Choose character set >choose the format of the database > click go.
Picture guide below
We are all set on our database setting process. Now, we are reaching the end of the process. We need to do a few more things.
Step 4: Change the database details on wp-config.php
wp-config file is located on htdocs/wordpress/
See this photo below on how to change the detail on your wp-config.php file.
Don’t change anything more than what is said on the instruction.
Do not change “DB_HOST“, Set DB_ HOST to localhost
We have finally reached the end this is the only one thing you need to do is upload the website files to the server.
To do so,
Open the FTP file transfer program or you can use the file manager on your cpanel to upload which is time-consuming and might crash. So, we will use FTP. We are using FileZilla for this guide.
Fill the host, FTP username, FTP password, and port(default port will be 21, you can escape filling the port).
Login to your FTP server.
Locate your WordPress file, which will be in your htdocs folder.
Select all and upload to your live site. Wait till all the files are uploaded.
We are done guys, we have reached the end of the guide, you should be able to reach your site now on the internet. If any of the posts links appear broken. Just log in to your WordPress dashboard > Permalinks > and don’t change anything just click the save changes. This will refresh your site links which will fix all the broken article links.
If you find this guide helpful please share this on every social media.