Uncorrupted Blog

Get the inside scoop from us dirrectly from our own blog

MAR17

Move WordPress With No Down Time

by Uncorrupted-Michael

pathingI’ve moved about 50 WordPress installations from various servers over the years and have found, what I consider, the “best practices”.   The goal here is to transfer your WordPress website off your current host’s server and (hopefully) onto one of the Uncorrupted Servers.   There are other ways of performing the migration, but I’ve found this to be the easiest. This guide assumes you have a basic understanding of terminal commands and that you can find your public_html directory on your current host’s server.

Requirements:

  • Terminal (SSH) access to your new and old web servers
  • An SSH client (I recommend Putty)
  • A text editor for modifying the dump.sql file we’re going to create (I recommend Aptana Stuido because it performs well when opening large (20+MB) text files)

During the migration process you’ll be copying/pasting paths a lot, so open up a new text document in Aptana and paste the following into it:

Old Server Info:
Path to public_html = /replace/with/real/path/
Wordpress DB Name = replace_Me
Wordpress DB User Name = replace_MeToo
Wordpress DB Password = NewSecretPassword

New Server Info:
Path to public_html = /home//domains/example.com/public_html/
Wordpress DB Name = replace_Me
Wordpress DB User Name = replace_MeToo
Wordpress DB Password = NewSecretPassword

Now open Putty and make a connection to your old server. Once you’re logged in, cd (change directory) into the public_html directory.
Type:

pwd

Paste the output into your text file. This is the path to public_html on the old server.

Log into your control panel and create a new database, copy the DB Name, User Name, & Password and paste it into your text document.

Back to Putty… you should still be inside your old hosts public_html directory. Type these commands:

cd ..
tar cvzf backup.tgz public_html
mv backup.tgz public_html

So, we moved up one directory and created a gzipped tar archive of your entire public_html folder. I choose to gzip the entire folder because if you’re in the directory and pass it the * operator it will skip hidden files (like .htaccess files), which we definitely want to leave in place. We also moved the backup file into your public_html folder so we can download it from the new server.

Open up another putty window and connect to your new server. cd into your public_html directory (@ Uncorrupted it is ~/domains/example.com/public_html/)
Let’s do some cleanup:

 rm -f index.html logo.jpg

Download and extract the backup file:

wget http://example.com/backup.tgz
tar zxvf backup.tgz
cd public_html
mv * ..

So, we downloaded the backup, extracted it, moved into the folder it created (public_html) and moved all the files out. We still need to move any relevant hidden files, so:

ls -la
mv .htaccess ..
mv
cd ..
rm -rf public_html

So now you’re back inside the real public_html directory on the new host. Grab the path and add it to your text file:

pwd

Lets tell WordPress which database to use and the username/password combo needed to open it:

nano wp-config.php

Find: define(‘DB_NAME’, ‘…’); Replace … with the DB Name in your text document
Find define(‘DB_USER’, ‘…’); Replace … with the User Name in your text document
Find define(‘DB_PASSWORD’, ‘…’); Replace … with the Password in your text document

Once you’re done editing the file, press + o to save the changes and + x to exit.

Let’s go back the the other Putty window (your old host) and dump the MySQL database – replace the DB info with the DB info from your text document.

cd public_html
mysqldump -u -p  > dump.txt

Download the text file to your computer and open it up with Aptana. We need to replace the path info throughout the database so click on Edit -> Find/Replace
In the find block, paste your old path to public_html and in the new block paste your new path to public_html. Make sure the Wrap Search check box is checked and click Replace All. Save the text document and upload it into your public_html directory on the new server.

Import the text file into your new MySQL DB:

mysql -u -p  < dump.txt

At this point, WordPress should be working. All of your posts, comments, media, etc should be working just as they were on your old host. You can test everything by editing the hosts file on your PC

Go to: C:\Windows\System32\drivers\etc and open up the hosts file with a text editor, go to the end of the file and type the IP address of your new server, press tab & type your domain name, save the document, close your web browser, and clean your DNS cache (click start, click run type ipconfig /flushdns & press enter). Next, open your browser and go to your site – everything should work. When you’re done testing, delete the lines you added to your hosts file and then save/close it.

At this point, all that’s left to do is change the DNS servers for your site and point them at the DNS servers provided by your new host. Some folks will continue to hit your old site and some will start hitting your new site. Within a couple days all your visitors will be hitting the new one. Keep in mind that it may be a while before you hit the new server too – that’s just the way DNS works. If you want to hit it instantly, check out my post about OpenDNS

Category :Technical Articles
Tags : none

Comments

  • the_guv September 29, 2009 @ 10:34 am

    this is mighty handy, thank you

  • Testing Your Website Before Switching DNS Servers on Domain Record December 13, 2009 @ 3:35 pm

    [...] Uncorrupted Hosting Blog:1 You can test everything by editing the hosts file on your [...]

Add your own Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Sidebar

Grab Our Button

Uncorrupted Hosting - High Performance Managed VPSs

Testimonials

  • testimonial Amy from Amy Loves it says:

    The assistance Uncorrupted has provided me has been priceless. My website would not be what it is without their service.

  • DealSeekingMom.com Testimonial Tara from Deal Seeking Mom says:

    The service that Uncorrupted provides just does not even compare to other hosting companies. I feel secure in knowing that my site is in excellent hands, and I greatly appreciate the personal attention I receive when I need assistance with the technical aspects of my site.

  • couponing101.com testimonial Stephanie from Couponing 101 says:

    Uncorrupted has far exceeded my hosting expectations! You cannot find a more knowledgeable, helpful, and reliable hosting service anywhere else! The tech support provided is invaluable! You won’t be disappointed with Uncorrupted!

  • FaithfulProvisions.com Testimonial Kelly from Faithful Provisions says:

    I have been with a few other hosting providers and NONE even compared to the service I have received with Michael and Uncorrupted. I promise you, you won’t find service like this anywhere.

More Testimonials
compassion

We're loyal donators to Compassion International, a Christian child advocacy ministry that releases children from spiritual, economic, social and physical poverty and enables them to become responsible, fulfilled Christian adults.





Copyright © 2010 Uncorrupted Hosting. All rights reserved. Follow us on TwitterBe our Facebook Fan
Latest Blog Post:

Playing with snort and pfSense

We've been having a blast with some new intel atom based pfSense firewalls here in the office. The d510 boards perform amazingly well, even with a slew of snort...


Visit our Blog