Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I recently switched a WP site from shared hosting to a VPS and would like to document the process here.

share|improve this question

3 Answers 3

Put old host in read-only mode

  1. Go to WP Admin -> Settings -> Discussion and check "Users must be registered and logged in to comment"
  2. Disable authentication:

Create a PHP file inside the wp-content/mu-plugins folder, with the following content:

<?php
function wp_get_current_user() {
    return new WP_User(-1);
}

This will prevent all logged-in users from leaving comments or creating posts on the old host.

Copy files and database to new host

I used FTP for transfering files and phpMyAdmin for exporting/importing the DB.

Handle DNS

  1. Point your domain to the new host's IP address.
  2. Wait for propagation to take place.

Once the new DNS settings have propagated fully, you can nuke the old host.

share|improve this answer
2  
Just wanted to add if you change the TTL you won't have to wait as long, many hosts have a TTL of up to 24hours, you can set this to 5 minutes before the big move and then back again after ( or don't the server will usually auto set it back to defualt since they don't want you pinging every 5 minutes). –  Wyck Mar 3 '11 at 5:49

Here's a very comprehensive guide if someone can help me format it correctly. Sorry, I don't have the time right now to figure out the formatting...

A. FTP-copy all theme and wp/upload files from {old_site} to {new_site}

  1. Use FTP client to copy from {old_site} to temp folder on local machine

  2. Copy from temp folder to {new_site}

B. Backup (export) existing database (from old_site)

  1. Login to your web hosting control panel. Click on your equivalent of “Database admin”.

  2. Examine file wp-config.php in the temp folder of local machine, look for DB_Host and DB_Name. They corresponds to the Hostname and Database value in the DreamHost Web Panel.

  3. Click on “phpMyAdmin” for the matching hostname. A user name and password prompt appears.

  4. Enter your MySQL user name and password. The phpMyAdmin user interface appears.

  5. On the left pane, click the popup menu item (databases) .... A list of MySQL databases on this server appears.

  6. Select the database which you wish to back up from the list. Information on that database appears in the right pane.

  7. On the tabs across the top, click Export. A pane marked "View dump (schema) of database" appears.

  8. Underneath the list marked "Export", click the link Select All. All the table names will be highlighted.

  9. In the radio button set below, make sure SQL is selected. This selects the output format.

  10. In the section marked "Structure:", check the box marked Structure:. Within this section check boxes marked Add AUTO_INCREMENT value, and Enclose table and field names with backquotes

  11. In the section marked "Data:", check the box marked Data:. Within this section check boxes marked Use hexadecimal for binary fields. If you are backing up a large (how large???) database, uncheck extended inserts as when you restore the backup the server may not accept such long SQL commands. If you plan to apply the backup to a database with a different structure (e.g., you applied a mod to PhpBB) or to an updated version of a web application, check complete inserts, otherwise leave it unchecked. Leave other boxes unchanged.

  12. Check the box marked Save as file.

  13. In the box marked "File name template:", fill in the name you want the backup file to have. phpMyAdmin expands certain abbreviations in this string: SERVER expands to the server name, DB expands to the database name, and a string like %Y%m%d is expanded according to the rules of PHPs strftime function.

  14. Click Go button.

  15. Save file on local machine.

C. Create new database

  1. Login to your web hosting control panel. Click on your equivalent of “Database admin”.

  2. Scroll down to “Create a new MySQL database”

  3. Enter new values for Database Name and hostname.

  4. Create new username/password values (or re-use from original wp-config.php file)

  5. Click “Add new database now!” button.

  6. (Optional) Wait for new hostname to be created.

D. Restore (Import) to new database

  1. Login to your web hosting control panel. Click on “My SQL Databases”.

  2. Click on “phpMyAdmin” for the matching hostname of the new database created in step 3b. A user name and password prompt appears.

  3. Enter your MySQL user name and password. The phpMyAdmin user interface appears.

  4. On the left pane, click the popup menu item (databases) .... A list of MySQL databases on this server appears.

  5. Select the new database you created in step 3b.

  6. On the tabs across the top, click Import.

  7. In the pane labeled “Fiile to Import”, click the “Browse...” button and select the sql file you exported at the end of step 2. Leave other boxes/values unchanged.

  8. Click Go button. The database should be imported successfully.

  9. Select the new database you created in step 3b.

  10. From the list, look for the table name that starts with “wp” and ends with “_options”.

  11. Click on the small icon indicated as Browse.

  12. A screen will open with a list of the fields within the table.

  13. Under the field option_name, scroll down and look for siteurl.

  14. Click the Edit Field icon which usually is found at the far left at the beginning of the row.

  15. The Edit Field window will appear.

  16. In the input box for option_value, carefully change the URL information to the new address.

  17. Verify this is correct and click Go to save the information.

  18. You should be returned to your wp-options table.

  19. Look for the home field in the table and click Edit Field. Note There are several pages of tables inside wp_options. Look for the > symbol to page through them.

  20. In the input box for option_value, carefully change the URL information to the new address.

  21. Verify this is correct and click Go to save the information.

E. New site FTP file modifications

  1. Delete the folder wp-content/cache for the {new_site}

  2. Update the file “wp-config” on the local machine by updating the fields with the values from steps 3b and 3c:

    a. 'DB_NAME' : Database name

    b. 'DB_USER' : Username

    c. 'DB_PASSWORD': Password

    d. 'DB_HOST': server MySql is running on

    e. Make sure to update the TABLE_Prefix to the same value listed in step 4j.

  3. upload the changed wp-config.php file to {new_site}

  4. (optional) Delete temp folder from local computer

F. Update

share|improve this answer

John Metta: WordPress and Github? Not as crazy as you think!

That's not really an answer, but a nice talk that shows a pretty seamless process.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.