Monday, December 19, 2011

How To Move Wordpress Website From Localhost To The Destination Server


A good guide on Posting your offline local test Wordpress site to your online web server. Thank Revolution Media for this great info. It work for me, and I think it will for you too. The original post is here


Did you ever experienced hard times trying to get your hand crafted Wordpress website transferred from your local test environment to the destination server? Did you spend countless hours trying to make things work? If you can answer yes to these questions then this article is for you. I’ll explain in plain English how to make a smooth transition from you localhost to the destination server.
Before we begin, I need to make some assumptions:
  • You have your website working perfectly on your local machine.
  • Local environment is either a PC or Mac on which you run a web server with PHP and a MySQL database and you have access to phpMyAdmin.
  • Destination server runs Apache or IIS, you have FTP details, access to phpMyAdmin, database server name, database name, database user name & password.
  • Other configurations may work as well.
  • It doesn’t matter which version of Wordpress you are using.
Also, a quick “executive summary” of all the steps below:
  1. Export your local Wordpress database to a text file.
  2. Search and replace http://localhost/yoursite with http://www.yoursite.com
  3. Create a database on your destination server and import your database.
  4. Copy all files from your local machine to destination server and amend wp-config.php file with new database details.
  5. If necessary change file and folders permissions so Wordpress will be able to use them.

Step 1 – Export Local Database To Text File

Open up your browser and access phpMyAdmin and select your website database from the drop down box on the left. This may look like this:
step1a
Step 1a (click to enlarge)
Go to Export section (click on the Export tab at the top). Depend on your version of the phpMyAdmin this section may look bit different but the functionality will be the same.
Click ‘Select All’ in the Export form. All tables should be selected now. Leave other options as they are. Navigate to the bottom and tick ‘Save as file’ checkbox. Click ‘Go’.
Step 1b (click to enlarge)
Step 1b (click to enlarge)
step1c
Step 1c (click to enlarge)
File save dialog will appear. Click OK and save that SQL file on your computer. Step 1 completed. Get yourself a coffee.
Step 1d (click to enlarge)
Step 1d (click to enlarge)

Step 2 – Search & Replace

Now, we have to change your database export file and find & replace all URLs that contain http://localhost/yoursite with http://www.yoursite.com
I’m using Dreamweaver but you can use any text editor to do the same.
Step 2a (click to enlarge)
Step 2a (click to enlarge)
We have to change another line as well. Find line C:\\Program Files\\xampp\\htdocs\\yoursite/wp-content/uploads and strip it down to /wp-content/uploads and finally save your SQL file.
Step 2b (click to enlarge)
Step 2b (click to enlarge)

Step 3 – Import Information Into Destination Server Database

On your destination server you have to create database for your WP installation. It may look like this screen below (assuming you’ll be using phpMyAdmin) However in most cases you’ll have to log onto your server administration panel and create database, user and password from there. It varies from provider to provider so please refer to your hosting provider help section.
Step 3a (click to enlarge)
Step 3a (click to enlarge)
Now as you have your database created you should populate it with your data. Click on the Import tab at the top of the page. Click on Browse in the ‘File to import’ section and select your amended SQL file. Click Go to proceed.
Step 3b (click to enlarge)
Step 3b (click to enlarge)
If everything went well you should see table names on the left hand side and a message saying something similar to this: ‘Import has been successfully finished, 162 queries executed.’ You’re done and deserve another coffee.
Step 3c (click to enlarge)
Step 3c (click to enlarge)

Step 4 – Upload Wordpress Files

In this step you should use your favourite FTP client to upload all files to your destination server. If you created a brand new website than you can upload everything including index.php file. If you upgrading an existing website then you have to make sure that it will work until you launch your WP website. DON’T DELETE ANY FILES that belongs to your existing website. Make sure your Wordpress website works first, then you’re safe to delete the old files.
To make your website work you should update wp-config.php file with your database details: database name, database server address, database user and password. Once done, you should be able to see your new website at http://www.yoursite.com/
Now, you have to test if you can login to the administration panel. So type in http://www.yoursite.com/wp-admin/ to find out. If you can see WP admin login screen you’re half way there. Type in your login details and login. If you’re successfull you should see WP Dashboard.
That’s it. You’re done.

Step 5 – Fine Tuning your Wordpress website

Few other thing you should take care of:
  • Make sure that you can upload any new images or documents. If you can’t it means that you have to change files/folders permissions and give Wordpress read/write right for necessary folders.
  • Check if your permalink structure works. Amend if necessary.
  • Make sure you’re running the latest version of Wordpress and upgrade automatically to the newest one where possible.
  • Check if you have installed latest versions of any plugins that you’re using. Be careful though! Some plugins require PHP5 to work properly or require additional libraries to be enabled. Check this prior to any upgrades.

2 comments:

Douglas Tay said...

Thanks for your sharing. :-)

damion said...

HPE0-S51 exam dumps - HP HPE0-S51 free demo, real HPE0-S51 exam dumps, latest Building HPE Data Center Solutions questions and answers

Emax Search Engine

Custom Search