Move WordPress Site from Localhost to Live Server: Step-by-step Tutorial with Screenshots
As developers, we usually choose WordPress to design websites in our PC first. We generally install a local server (popular known as localhost) using Xampp (for Windows OS), Mamp (for Apple OS). Yet, most of us are unaware of the proper way to bring it to live server later on.
Even knowing is not enough, make it look identical and many features seem to be missing in the process. So, today I’m gonna give you a complete tutorial about moving a WordPress site from local server to live server.
- First of all, you need a domain and hosting.
- The domain name must be properly resolved to the hosting. Changing to hosting servers NS Address generally resolves it. (To get assistance, contact with your hosting provider)
- Permission to create MySql database and FTP Access. It is preferable to have an access to the cPanel (assuming you are using Linux-based web hosting).
- FTP client software FileZilla. You can download FileZilla from its official website.
Database Export from Local Server
Since, we will use your local server's database in live server, you need to export it to a compressed (.zip) text file. Go to ‘phpMyAdmin’ section of your local server (http://localhost/phpmyadmin). Select your database from the list on the left side/corner. Now click on ‘Export’ like the following image.
Click on the "Go" button without making any further changes. A file should be downloaded in .zip file format, save that.
WordPress Upload and Extract Files from cPanel
It takes a lot of time to upload files one by one with FTP software. So, zip all the files of your website that you have built on your localhost. Then upload that .zip file with FileZilla to the root folder of the live server. Wait until uploading is complete.
Login to your hosting cPanel. Click on the "File Manager" icon. You will be redirected to your hosting server's file manager.
You should see your .zip file (which is the only file). Click on your .zip file and press the "Extract" button. Wait for a while. All your files will be extract as you had on your localhost.
Creating MySql Database on Live Server
Now we need to create a new database. Login to your hosting’s cPanel (hope you are already logged-in), Click on MySql Database by scrolling down like the image below.
You’ll get a page like the following image:
Now select a name for your newly made database and click "Create Database".
Once done, scroll down to "Add New User" section. Create a new database user here
At this point, we have created a new database and a new user. Now, I shall add this user to our database and set access privilege to the user. Under "Add User To Database" section, I shall select my user and the database from dropdown combo boxes and click on the "Add" button. This will bring me to a new page like the image below. Click on the "ALL PRIVILEGES" selecting all the privileges listed below and again press the "Make Changes" button. Press "Go Back" button at the end.
Thus I have completed making database, user, adding the user to the database with appropriate access privileges to the user.
Go to cPanel's homepage, scroll down to "phpMyAdmin" and click it. Click your new database (which you have just created) from the left section. Then click on "Import" from the Menu bar.
Now, click on the "GO" button at the bottom of the page. The database would be imported after a short while.
Changing Website’s URL
Since our previous website address was in "localhost", we need to replace it with our new domain’s address. Open the database from phpMyadmin and browse the "wp_options" table.
You’ll get a field named "siteurl" here.
Click on the edit button of "siteurl" field. Change your previous localhost address (http://localhost/wp473) by adding your new address (domain name, http://example.com/) here.
Pay close attention so that the URL format is right. Put the URL in the following format:
Save the record pressing the "GO" button at the bottom of the page. This will bring us back to the listing page of "wp_options" table. In the similar fashion, change the value of "home" field with correct URL, in our case, "http://domain.com/"
Now visit your site without any worry. You’ll see an error like this:
"Error Establishing Database Connection"
That means your site is unable to connect to the database.
To solve this problem, switch to File Manager tab in cPanel. Find the "wp-config.php" file and open in edit mode.
Now, change your new database setting values as the following:
define('DB_HOST', 'localhost'); [Do not change it unless your hosting company provides a new value for DB_HOST]
You need to rewrite your site’s permalink. Go to ‘permalink’ from Settings and click on the ‘save’ button.
Media Link Update
Most people ends just right at the previous step. Consequentially, the images remain out of sight. In order to see those, you must update the image links.
Go to cPanels’s phpMyAdmin to update your post’s media link and select the database you have just imported.
Click on SQL from the top menu bar and run the following query:
Edit the query with your local server address and your present address.
UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.domain.com/');
Congratulation! You have finally moved your WordPress site to your hosting server.
I hope that your WordPress is running as expected. I tried to explain as simply as possible. I have tried to keep everything simple, (because. it's WordPress, thanks) and hope you will find it so.
- Category: WordPress
Setup a cron job that runs on every 15 minute using Crontab in Ubuntu 16.04
Ubuntu 27-09-2017 Hits: 197
Do you want to be an SEO expert?
SEO 10-07-2017 Hits: 455
How to Increase the Views of YouTube Videos in Organic Ways
Social Media 04-06-2017 Hits: 702
Facebook Ad Retargeting: How Does Facebook Get The Whereabouts of Our Visited Websites?
Social Media 21-05-2017 Hits: 715
Increase Twitter Engagement: 11 Easy How-Tos
Social Media 11-05-2017 Hits: 740
How to Use WordPress Custom Logo API: With Code Example
WordPress 07-05-2017 Hits: 1177
10 Important WordPress Plugins and Tools for SEO to Rank Your WordPress Website Even Better
WordPress 20-04-2017 Hits: 1280
Most Read Tutorials
How to combine all .vcf files to single .vcf file manually to merge into Gmail Contacts
Webmaster 23-05-2015 Hits: 75244
Get component, module and plugin parameters in Joomla 3
Joomla 3.0 24-07-2014 Hits: 33982
How do you detect a website visitor's country?
Webmaster 30-05-2013 Hits: 19071
Troubleshooting Joomla 3.0 Database Connection Errors
Joomla 3.0 17-03-2013 Hits: 18599
Fixing JFolder::create: Path not in open_basedir paths
Joomla 3.0 22-02-2014 Hits: 17052
How to setup SMTP in Joomla 2.5 to send emails
Joomla 2.5 23-07-2012 Hits: 16675
Open a Port in Firewall in Windows 7 OS
Windows 18-07-2012 Hits: 15677
How to add Google Analytics code in Joomla! 2.5 template
Joomla 2.5 14-07-2012 Hits: 15656
How to fix 'Creating default object from empty value' PHP warning in Joomla
Joomla 3.0 23-10-2013 Hits: 15264
Using Popover on Hover with Twitter Bootstrap in Joomla 3
Joomla 3.0 06-07-2013 Hits: 14776
Store user state variables in Joomla 2.5/3.0
Joomla 3.0 24-03-2013 Hits: 14423
NetBeans auto completion does not show class methods when using Singleton design pattern
Joomla 3.0 24-02-2014 Hits: 9319