Moving WordPress

This howto will explain how to move WordPress from one domain or server to another with about 5 minutes worth of work.

Applicable to Centos Versions:

  • Centos 5.x
  • Centos 6.x

Requirements

Explanation of requirements.

  1. Admin or root access to the old or existing website, database, database dump and files.
  2. Admin or root access to the new server.
  3. A basic understanding of Linux, Mysql and WordPress.

Doing the Work

This howto assumes your domain name already resolves to the new server and you’ve already uploaded the core WordPress files, custom themes and any plugins in to the proper httpd docroot.

  1. Take a mysqldump of the database to be moved and save it locally.
  2. mysqldump -u root -pmypass mydatabase > mydatabase.sql
    replace "mypass" with your password, no spaces between your password and the -p
  3. Change the old WordPress Address (URL) and Site Address (URL) in the database using sed.
  4. sed -i 's/example1.com/example2.net/g' example_wpdb.sql
    
    In this example we're replacing any occurance of "exmaple1.com" with "example2.net" in the example_wpdb.sql database.
    
    a. Create a new empty mysql database with the same name as the one you're importing on the target server.
    b. Import this new, edited database on the new target server.
  5. Edit wp-config.php
  6. Add this on a separate line by itself near the end of the wp-config.php file after all the other "define" statements:
    
    define('RELOCATE',true);
    
    a. Save and upload wp-config.php to the new server.
    b. Load the site, login to the wp-admin
    c. Go to: settings --> general and make sure the addresses are correct.
    d. Again, edit the wp-config.php and remove completely or comment out the previously added define statement like this:
    /*define('RELOCATE',true);*/
    

Troubleshooting / How To Test

Explanation troubleshooting basics and expectations.

  1. Take a good look at the steps above and make sure you’ve followed them in precise order.
  2. Stop where things stop working as expected and take note of any error or unexpected output or behaviors.
    
    Also make sure to be prepared with your:
    Linux version
    httpd(Apache) version
    php version
    MySQL version

Common problems and fixes

Disclaimer

We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #centoshelp or #wordpress on irc.freenode.net

Added Reading


© 2012 CentosHelp.org