I recently switched a WP site from shared hosting to a VPS and would like to document the process here.
Leave a Reply
You must be logged in to post a comment.
I recently switched a WP site from shared hosting to a VPS and would like to document the process here.
You must be logged in to post a comment.
Put old host in read-only mode
Create a PHP file inside the wp-content/mu-plugins folder, with the following content:
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
Once the new DNS settings have propagated fully, you can nuke the old host.
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}
Use FTP client to copy from {old_site} to temp folder on local machine
Copy from temp folder to {new_site}
B. Backup (export) existing database (from old_site)
Login to your web hosting control panel. Click on your equivalent of âDatabase adminâ.
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.
Click on âphpMyAdminâ for the matching hostname. A user name and password prompt appears.
Enter your MySQL user name and password. The phpMyAdmin user interface appears.
On the left pane, click the popup menu item (databases) …. A list of MySQL databases on this server appears.
Select the database which you wish to back up from the list. Information on that database appears in the right pane.
On the tabs across the top, click Export. A pane marked “View dump (schema) of database” appears.
Underneath the list marked “Export”, click the link Select All. All the table names will be highlighted.
In the radio button set below, make sure SQL is selected. This selects the output format.
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
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.
Check the box marked Save as file.
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.
Click Go button.
Save file on local machine.
C. Create new database
Login to your web hosting control panel. Click on your equivalent of âDatabase adminâ.
Scroll down to âCreate a new MySQL databaseâ
Enter new values for Database Name and hostname.
Create new username/password values (or re-use from original wp-config.php file)
Click âAdd new database now!â button.
(Optional) Wait for new hostname to be created.
D. Restore (Import) to new database
Login to your web hosting control panel. Click on âMy SQL Databasesâ.
Click on âphpMyAdminâ for the matching hostname of the new database created in step 3b. A user name and password prompt appears.
Enter your MySQL user name and password. The phpMyAdmin user interface appears.
On the left pane, click the popup menu item (databases) …. A list of MySQL databases on this server appears.
Select the new database you created in step 3b.
On the tabs across the top, click Import.
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.
Click Go button. The database should be imported successfully.
Select the new database you created in step 3b.
From the list, look for the table name that starts with âwpâ and ends with â_optionsâ.
Click on the small icon indicated as Browse.
A screen will open with a list of the fields within the table.
Under the field option_name, scroll down and look for siteurl.
Click the Edit Field icon which usually is found at the far left at the beginning of the row.
The Edit Field window will appear.
In the input box for option_value, carefully change the URL information to the new address.
Verify this is correct and click Go to save the information.
You should be returned to your wp-options table.
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.
In the input box for option_value, carefully change the URL information to the new address.
Verify this is correct and click Go to save the information.
E. New site FTP file modifications
Delete the folder wp-content/cache for the {new_site}
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.
upload the changed wp-config.php file to {new_site}
(optional) Delete temp folder from local computer
F. Update
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.