Move WordPress from localhost to Webserver

move-wordpress
For a while now, WordPress has been my favorite option for providing clients with a Content Management System. And since the release WordPress 3, it’s become the easiest sale on the planet. After showing them a demonstration, 75% of the time, the client loves it, and it persuades them to pay double the price they would have paid for a generic ol’ static website. It’s amazing how much WordPress 3’s menu builder has had such an impact on the entire software and the overall presentation of it.

So, needless to say, I’ve been churning out a lot of WordPress sites recently at the agency. In this post, I’m going to talk about that last step you take in delivering your shiny, new WordPress site to your client filled with all of their content.

Generally, you’re not going to build the website on your client’s live domain. I usually develop the initial WordPress theme and put in whatever parts of the content I have at the start of the project locally on my computer using MAMP. Then I’ll transfer that site to a dev server where the client and everyone else my agency can view it. After a billion rounds of edits and changes, it’s finally ready to go live, and so then it’s transferred to the client’s live domain.

In creating all of these sites, it’s absolutely crucial to be transferring WordPress correctly. Your concern should be developing your client’s website and not struggling with elementary things like installing and moving around WordPress. If you’re new to the process of moving WordPress, don’t worry. I’m going to explain in it detail. I also would suggest that you practice moving WordPress a few times to different servers. After a few times, you’ll get the hang of it, and see how easy it is. If the first time you’ve ever moved WordPress is the time when you’re putting you client’s site live, you are putting yourself at some serious risk for embarrassment.

Keep in mind that if you’re simply moving your personal WordPress site a new server, all of the following steps are the same.
The Quick Version

To start with, here is a quick version of the process of moving your WordPress site from one to server to another. Even after you’re familiar with the process, it’s not a bad idea to have a checklist of all the steps you need to take sitting by your desk.

moving-wordpress
If all of those steps weren’t clear, don’t worry; I’m going to explain each one. In the following steps, I’m going to show some screenshots from when I transferred the demo site for my Complexity WordPress theme from my local computer to my live demo website.

Just 10 Steps Away to Move on

    Step 1

Export a copy of your dev site’s MySQL database as an SQL file.

The first thing I do is make a copy of the dev site’s database. Login to phpMyAdmin on your development server and export a copy of database.

When you do this, make sure you are actually within the database. You should see all of the tables of your WordPress installation as the screenshot below shows. Then, click “Export.”
export1

Next, configure your export file as I have in the screenshot below. Make sure you have all tables of your database highlighted on the left side. Also, make sure you have the “save as file” checked at the bottom. Click “Go” and a copy of your database should be saved to your computer as an SQL file.
export2

    Step 2

Open this SQL file in a text editor and do a mass find and replace of your dev site URL with the new server’s URL.

Update:For the most accurate results when transferring your WordPress database, do not follow how it’s outlined in this step. The problem here is that much of your data in your WordPress database is serialized, and when you simply open up the SQL file and start changing the text, you will most likely get varied results. — For example, most of your data may transfer, but maybe your theme options won’t transfer, all of your widget data might not transfer, etc.

So instead, to perform this find/replace step of your site’s URL, I strongly suggest you temporarily upload the following PHP file to your live site and follow its steps:

http://interconnectit.com/124/search-and-replace-for-wordpress-databases/

Open up the SQL copy of your dev site’s database you exported in the last step in a decent text editor like Dreamweaver, Coda, Textmate, Netbeans, etc. Avoid using a default text editor that comes with your computer (like Notepad with Windows, for example). With large files, sometimes screwy things can happen.

Do a mass find and replace of your dev site’s URL with your new server’s URL.

This is a very important step. If you do this properly, all of your hyperlinks throughout your entire WordPress site will linked up properly on the new server (i.e. manual links you put to other pages in your content, links to images you’ve uploaded, custom links you’ve used in the menu builder, etc.)

I personally use Coda for Mac OSX for all my coding, and below is an example of how to do a mass find and replace with your database SQL file in Coda.
find_replace1
I know Dreamweaver is much more popular, and so here is a screenshot of doing the exact same thing in Dreamweaver.
find_replace2

    Step 3

Make a copy of your dev site’s files so they’re ready to upload to the new server.

I personally feel it’s a good idea to actually make a copy of the files of your dev site because if you screw something up, it’s nice to know you have a fully functional dev site still sitting somewhere. So, make a copy of all files, meaning your entire installation of WordPress.

If you have your website locally because you’re using MAMP or WAMP, make a copy of the files. If you have your dev site on a live web server, download all the files to your local computer.

Important Note: Confirm everything in your wp-content directory gets copied. This directory contains everything crucial in the actual configuration of your WordPress site – Themes, Plugins, and Uploads.
important_ftp
Step 4: Create a MySQL database on your new server.

If you’ve created your dev site, I’m going to assume you know how to create a MySQL database. So find where your new server’s database management is (usually in cPanel or whatever similar software your web hosts uses) and create a new, empty database and assign a new username and password to it.