Moving WordPress from localhost to Web Server
In our previous tutorial, we learnt that how to Install WordPress on local Computer using wamp server. As you have seen that development process become very fast and you have great opportunity to explore without any fear and making mistakes on local computer. When your web development is completed on localhost. Now this is the time to move your website from localhost to live server.
Before your site going live, we need to transfer our local website data from localhost to web server or ftp server. Everything of your website is stored in MySQL database including images, posts and pages. There are two ways to export data. Either you can find any wp plugin which can make your work much easy so Backup-Buddy plugin is the best one to choose for database backup. Otherwise you can also do that manually by using built in wp tools as we will use this feature later in this article. If you need advance help then you can visit wordpress.org.
To get your local site data first login wordpress on wp admin and navigate to tools and open import option. You need to install wordpress importer because without installing this plugin you can not export data or data backup.
Once installed, go to export page where you can find all contents, posts or pages export options with download export file button.
I will highly recommend you to choose all contents option because it will export everything like posts, pages and images. By pressing download button an xml file will be saved on your computer and this is the actual backup file which you will use while live installation.
Finally we will export our local wordpress database by typing http://localhost/phpmyadmin/ or going into wamp server then phpMyAdmin and open database and click on export button. Click on go button will download your database.
Upload WP Latest Version
To make your site live you need web hosting and ftp server to upload your contents. Login to cpanel and open file manager and upload wp files or you can upload by using your ftp account.
Lets open ftp client, enter credentials and press connect button. Once connected you will see two panels, local site on right and remote site will show on left. Copy your localhost folder files and paste into the root directory on web server.
Creating new Database
Now next step is to create data for live site. Login to CPanel and go to databases section and open MySQL databases. Enter your database name and click on button to create sql database.
After that you will add MySQL user and then you will set MySQL privileges for that user under CPanel. Remember always grant all privileges to that user.
Now this is the time to import your wordpress database on web server. So go to databases section in CPanel and open phpMyAdmin and select the database which you have recently created. Right now this will be empty, you will upload your local database file by import option and this will update with local file.
When db file is updated then you will replace local website URL with live. Go to wp_options in phpMyAdmin and edit siteurl option. Replace local url (http://localhost/example/) to live url (http://www.example.com/) and press on save. You will find few more pages which urls need to be updated like home etc.
Once you done that now its time to install wordpress on web server. Before starting the process you must change wp-config.php file on public_html directory otherwise you will get very common issue Error Establishing Database Connection. Connect with your ftp client, open wp-config.php and enter database name, username and password and finally save this file. Remember put same information which you already have while creating database and user for this website.
Run website url, enter site information and press on install button. Congratulations your site is now live on internet.
Update WP Dashboard Settings
Login to WordPress and update the settings like general, reading, writing and the most important permalink. In this page you must select post name option. Al last save the general settings.
The most common issues missing your images and broken links which everyone of us face while transferring wp site from local server to web server or live server. You can fix that issue by many ways. You either change the path manually. This is good if you have few images and posts or pages. But if you have large number of contents and images then you can’t do it manually. So in this situation you can use SQL Query to fix this problem.
You can run the below SQL Query in phpMyAdmin under SQL Editor.
UPDATE wp_posts SET post_content = REPLACE(post_content,’localhost/example/’, ‘www.example.com/’);
After run that query, go through your website and double check that Is it working fine?. Congratulations now your website is live for the world.
In this article we discussed that how to install wordpress on web server. We also looked at local files backup, move files from local computer to live root directory. database configurations and finally the live site installation. Hopefully this will help you a lot.
I have also published another post about HOW TO MIGRATE WORDPRESS TO NEW HOST WITH DUPLICATOR Plugin .