Follow

Migrating your websites to a VPS server

  • Applies to: VPS Hosting
    • Difficulty: Medium
    • Time Needed: 60
    • Tools Required: SSH, FTP client, DNS Control

Overview

Whether you have a site with just static html pages or a dynamic database-driven one, this migration guide will help you get started with your new VPS server. This document is by no means comprehensive, but it should cover the basics to get you on your way.

Advanced Support Can Help!
Need help moving your site? Media Temple offers site migrations through Advanced Support, our premium services division.

Getting started

This guide assumes you still have access to your old host. We'll use and refer to elements of WordPress as an example for moving a site with dynamic content. Throughout this guide, there'll be both basic and advanced instructions.

STATEMENT OF SUPPORT
The publishing of this information does not imply support for this article. This article is provided solely as a courtesy to our customers. Please take a moment to review the Statement of Support.

Instructions

Order the server

If you haven't already, order your new VPS server. See Managing/Ordering servers for details. Here are a couple of things to keep in mind:

  • The new server cannot have the same domain as an existing service when ordered, although this can be changed later if desired.
  • Don't use a subdomain of a domain that's currently on another service. You can use something like new-example.com or a random string of characters like igw8aclrj2.net.

Lower your TTL

Lower your domain's TTL to minimize the time it'll take for the internet to update once you point your domain to your new VPS server.

Set up the new server

Set up the basic settings for your new server:

Transfer your site

Automated transfer

If you're moving from another Plesk or WHM/cPanel server, you can use the transfer tools available in your control panel GUI. These tools can move your website content, databases, and emails:

Manual transfer

If you need to move your website content manually, you'll need to:

  1. Recreate your website accounts in Plesk or WHM/cPanel
  2. Transfer your website files using FTP or SSH
  3. Transfer your databases using phpMyAdmin or SSH
  4. Recreate your email accounts in Plesk or cPanel
  5. Transfer your email accounts over IMAP

Site Paths and Previews

In most cases, you will not need to worry about updating site path references in your website code. Most modern applications and coding practices encourage using relative paths and variables.

However, there are some cases where your website will appear to be broken after a site migration. This is because every host has a different design and preference for their directory structure. One important thing to mention is that WordPress, and many other apps, have a configuration setting for the domain name. If you try to preview your website using your IP Address, you may experience display problems. For this case, you must change a setting to preview your domain before changing DNS.

This can be accomplished by running the following command in the SQL tab of the phpMyAdmin on your new VPS:

 UPDATE `dbname`.`wp_options` SET `option_value` = 'http://xxx.xxx.xxx.xxx' WHERE `wp_options`.`option_id` =1 AND `wp_options`.`blog_id` =0 AND CONVERT( `wp_options`.`option_name` USING utf8 ) = 'siteurl' LIMIT 1 ;

After you've previewed your site and want to revert back to your actual domain, run the following command:

UPDATE `dbname`.`wp_options` SET `option_value` = 'http://example.com' WHERE `wp_options`.`option_id` =1 AND `wp_options`.`blog_id` =0 AND CONVERT( `wp_options`.`option_name` USING utf8 ) = 'siteurl' LIMIT 1 ;

You may need to do similar modifications to other apps. Always consult your software's documentation.

Database Connection Strings

Any website that utilizes a database must be able to make a connection. When moving to a new host, it's important to know where your database connection strings are located so you can update them to work with your new environment. Popular CMS applications such as Joomla, WordPress, Magento, Gallery, and others tell you what file to edit in the software documentation. For WordPress, this is in the wp-config.php file.

Via SSH

If you want to find all files containing a database connection string, run this from your website root directory:

 grep -rl "localhost" *

This will search all plain-text files for the string localhost and give you a simple list to go through. The reason we're searching for that is because localhost is the hostname that the majority of hosts use, so you have a good chance of finding your config file if you look for that phrase. You can set your new database username, password, and database name from inside Plesk.

An example of the correct setting for a VPS is:

  // ** MySQL settings ** //
  define('DB_NAME', 'dbname');// The name of the database
  define('DB_USER', 'dbuser'); // Your MySQL username
  define('DB_PASSWORD', 'tH15i5myP4SSW0rd'); // ...and password
  define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value

Test your site

Test using your IP address

After you've transferred your website content, you can preview your site using your IP address or your control panel GUI:

Change DNS settings

Once you're ready to direct customers to your new server, you can change DNS to your new server.

If you've lowered your TTL and waited for the original time interval, then the DNS propagation should be about 5 minutes. If you haven't, then you'll need to wait about 24-48 hours for DNS propagation to complete.

Double-check migration accuracy, cancel old service

Once you've thoroughly tested your new server and have confirmed that your DNS changes have propagated, you can close your old server.

You now have the option to update the primary domain of your new server if desired.

Resources

Was this article helpful?
0 out of 0 found this helpful

Comments