Migrate your web site or blog to a new server with minimal problems or inaccessibility. This guide steps out a proven relocation procedure.
When I moved my site from my shared host to my shiny new VPS at Linode, this was a concern for me, particularly as I had a continually changing database. Scouring the web, I found some scant instructions but nothing thorough, and no tutorials that gave me confidence. So I asked at the Linode forum, and the process mapped out below is a recap of the advice given by the kind folks there, along with my own experience.
Setup Unmanaged VPS: The Ubuntu-Nginx Guide
Take your virtual private server from zero to hero
.. from blank box to cute-as server ..
with this easy-to-follow copy/paste guide.
22+ parts with video, here’s the index.
.. So, for this process, you can thank Linode forum users btmorex, Lykaon, kirbysdl and hybinet (hats off to you chaps!)
This guide refers to a shared-to-VPS move, but can be applied to any server-to-server move.
First up, Self-Service
DON’T TELL YOUR OLD HOST THAT YOU INTEND TO MOVE AWAY.
Sign up with a New Web Host
If you’re not sure what type of host you need, VPS (Virtual Private Server) vs Shared vs Dedicated will help you choose.
If you’re going the unmanaged VPS route, read Setup Unmanaged VPS: The Ubuntu-Nginx Guide from top to toe. If you are unmanaged, for the rest of this tutorial, I’ll assume you’ve built your box. For shared, managed VPS or dedicated, your box is built anyhow, so let’s skip on.
Create DNS Records
Basically, these tell a server to look for a domain.
If your new host doesn’t allow DNS configuration, that’s pretty poor. Else you’re with a shared server, in which case you get what you pay for. For those who can perform DNS administration ..
Add DNS records in your control panel so, for example, with Linode or Slicehost that’s done in the DNS Manager. You can refer to Add a Domain Zone to Your VPS for details and an explanatory video. Give everything a really low TTL (time to live) value. If you have any MX or other DNS records with your current host, replicate those.
Don’t worry, this doesn’t make your domain resolve to the new host prematurely, but does prepare it for the migration.
Twin the Old Site or Blog
Duplicate your site or blog’s file structure on the new server, create & link any databases and import your data within.
Web Site & Blog Setup Resources
Most of these tutorials have video guides as well as the copy/paste how-to. Note: some are Nginx-centric, but that’s generally regarded as the most efficient web server anyhow.
- To set up your VPS, refer to Set Up a VPS Linux Distribution .. and look at the rest of the series too for security and whatnot.
- If you’re using the Nginx web server, refer to Serve Multiple Sites & Blogs with Virtual Hosts.
- To set up the database or if you’re using WordPress, refer to WordPress Setup & Updates from the Command Line.
- For WordPress, you best also check out Set up WordPress on Nginx with Pretty URLs & WP Super Cache.
Amend Hosts File to Test Site or Blog
Top trick, this. You can alter the hosts file on your PC to redirect your URI to the new server, just for you. This doesn’t effect the original site at all so don’t worry about that. Open the hosts file like this:-
Windows
Goto my c: > windows > system32 > drivers > etc and open hosts with a text editor.
Linux
Mac
I don’t know. Please lemme know!
You’ll know it’s the correct file because it’ll have an entry or two like:-
… and that is the format you want for the new lines you have to add to the file. So add something like:-
… swapping the IP for your new IP, and the domain for yours.
Upon saving the file, when you surf to domain.com, instead of taking you to your old server, it will take you to the new one, and you can fully test your site’s functionality.
(I told you that was top
)
NOW TEST YOUR NEW SITE’S FUNCTIONALITY.
But don’t administer the wrong site: after testing, don’t forget to delete the new hosts entry, else comment it out with a # at the beginning of the line. And restart your web browser.
Resolve Email
Move your email accounts from your current host.
If you want a simple, spam-free solution with no web server resource cost (ie no personal mail server), check out the Google Apps for Domain-Specific Email.
Test your email.
Create A or AAAA Records
This is the key to a seamless move, which is particularly important if, for example, you host a forum or receive a lot of blog comments.
What we’re going to do is to set up your new host to resolve the domain call to your old host. Basically, this eliminates the possibility of writing to more than one database while, for example, the nameservers propagate or Google’s global servers refresh your new domain details.
In the new server’s DNS settings, add two A/AAAA records using these guidelines:-
| Hostname | IP | TTL (Time to Live) |
|---|---|---|
| domain.com | old web host IP address | shortest option |
| www.domain.com | old web host IP address | shortest option |
When you save your options, you may find one of the hostname fields is blank. That’s normal.
Point Domain to Nameservers
Goto your domain registrar account and look for the Nameserver option. Renew the data.
For example, with Linode, bless, change to ns1.linode.com, ns2.linode.com, ns3.linode.com and ns4.linode.com. You’ll find your new web host’s nameserver details easily enough.
Now we are awaiting full propagation, at all server points around the world. I have no idea how long that takes, but about 72 hours is generally reckoned, so allow for 4-5 days to be safe.
MOVING DAY!
Go back to those A Records we created, replacing the old host IP to your new host IP. Set the TTL to the shortest possible ‘time to live’. But before you click OK ..
Take a final backup of your old database and import the data into your new one.
.. And now you can click OK on those new A records.
While your A record changes will update the new host nameservers within minutes, it takes up to 72 hours for full web-wide propagation. You may find new data records in the old database, so you’ll have to export and import those strays.
Note: At Linode, updated DNS records take effect every 15 minutes. So if you edit an A record at 2:32, it’ll take until 2:45, plus the time period specified in the TTL, for the update to be visible to the world. Careful timing will give you the least downtime.
Final Checks
If you completed the previous testing properly, there should be no surprises. Then again ..
After the time period specified in the TTL, check your site to ensure everything works. Because your local nameservers may not yet have resolved with the new A record data, and so that you can be sure you’re looking at the new, not the old, web application, use the host file trick.
Shed Shared, Viva Virtual!
Whatever kind of web host you’ve moved to, you can cancel the old host 4-5 days after moving day. Your breathing will gradually shallow out. Take tea!
Virtually Done
This series is pretty much complete and I, for one, am definitely gonna spend more time down the pub.
Hold on, did I say complete?
God’s teeth, hot damn, that calls for a cigar. (Or at least for going to bed cos let’s face it, most folks wrap this stuff at c. 4am.)
I hope sincerely that you enjoyed it, that it was crystal clear, and please that you let me know anything at all that somehow got snagged.
By way of a follow up – and crucial for the proper ongoing maintenance of your virtual private server – check out the Ubuntu-Nginx VPS Guide appendices with particular attention to Nginx Control Panel Workarounds. That shows you how to administer your VPS without relying on crass bloatware like cPanel and, having completed this VPS series, that reference is your new-best-friend (apart from me and the forum, obviously).
Right, I’m off to prop up the bar, here’s the you-know-what ..
Setup Unmanaged VPS: The Ubuntu-Nginx Guide
Take your virtual private server from zero to hero
with this easy-to-follow copy/paste guide.
“My local PC runs Windows” Show me for Linux/Mac
“My local machine is Linux/Mac” Show me for Windows
22+ parts with video, here’s the index ..
-
Setup Unmanaged VPS: The Ubuntu-Nginx Guide
Introducing vpsBible’s how-to guide for setting up a super-charged unmanaged VPS featuring Ubuntu and Nginx.
-
VPS (Virtual Private Server) vs Shared vs Dedicated
Before getting stuck in, let’s compare the web host types in detail and weigh up the differences between managed & unmanaged VPS.
-
Set Up a VPS Linux Distribution
Opening a VPS hosting account, we’ll choose, configure & launch a Linux server ‘distribution’.
-
Set Up Command Line Interface (CLI) using PuTTY
Now we’ve got a server to play with, we’ll connect to it, using the ’ssh’ protocol for a super-secure link.
-
Create a Linux User & Set Permissions
Initially you’ve logged into your remote Linux machine as ‘root’. We’ll add you as a user now, with root or SuperUser permissions.
-
Encrypt Data with OpenSSH & Auto-Login with PuTTY
Now we can use ‘authentication keys’ to shore up our connection while simplifying login to an automated, password-free yet secure process.
-
Harden the Secure Shell (SSH) & Create a Firewall
The final security step: galvanizing the OpenSSH protocol and setting up an ‘iptables’ firewall. Now the server is rock ruddy solid.
-
Edit bashrc for User-Friendly Linux, plus System Updates
We use the terminal a whole lot so let’s cut ourselves a break and create some command shortcuts, then update the server.
-
Add a Domain Zone to Your VPS
To make your server aware of yourDomain.com you’ll need a few ‘DNS’ records. Damn this is simple I’m practically asleep!
-
Prepare Linux Server for Email with Postfix
In order to send and receive email from our web applications we’ll install some software and tweak the ‘RDNS’ record.
-
Install PHP5 & MySQL – The One-Stop FastCGI Index Page
Add PHP5 & MySQL, but which FastCGI method is best? Here’s the benchmarking, 4 ways to install/compile, add caching modules & more.
-
Nginx (better than Apache) Web Server
Let’s install this supersonic web server, tweaking its file structure & adding default configuration files.
-
Setup FileZilla for Secure FTP (SFTP)
There’s FTP, and then there’s ‘Secure FTP’. We’ll set up FileZilla using SFTP – and those authentication keys – for secure file transfers.
-
Serve Multiple Sites & Blogs with Virtual Hosts
We want a website folder structure, some permissions, some site-specific configuration files and, hey, we’ll hook up ‘FastCGI’.
-
Adding Sub-Domains with Nginx
Need a sub-domain? If you do, here’s how to add subDomain.yourSite.com with an ‘A record’ and a configuration file.
-
Integrate A CMS Like WordPress, WP MU, Drupal etc
For those of you wanting to use a specific content framework, such as a CMS, blogging or forum software, pop in here and we’ll sort that out.
-
Google Apps for Domain-Specific Email
GA’s free Standard Edition for catchall webmail – POP-ping or IMAP-ped to your desktop client – saves precious server resources for your webs.
-
Moving Day! How to Move Your Blog or Site
Nearly there. Here’s the web site or blog migration guide, relocating to your VPS with minimal or no downtime.
Manage Unmanaged VPS: Ubuntu-Nginx Administration
Already set it up? We’d best maintain it then.
Toggle to the .. Ubuntu-Nginx Admin Index
Manage Unmanaged VPS: Ubuntu-Nginx Administration
Maintain your virtual private server with ..
.. cheatsheets, tutorials, tips & guides.
Head back to the .. Ubuntu-Nginx Installation Index
-
Nginx Control Panel: Here’s the Deal
You’re migrating shared-to-VPS and want a GUI like cPanel? No you don’t, not after you read this! What’s more, you don’t need one either.
-
Nginx Control Panel Workarounds
For every control panel module there’s an equivalent (and faster) terminal command. Let’s compare these.
-
Upgrade to Nginx Latest Version with ZERO Downtime
Keep Nginx up-to-date – and optimized for security. This guide shows precisely how *with no missed server requests*.
-
Compile an Advanced Nginx Module Configuration
Need special web server functions? Here’s how to install or upgrade Nginx with bespoke required modules & parameters.
-
Add Web Sites Nginx Cheatsheet
Once you’ve set up your first site, adding more gets easier. Especially when you refer to this. (Let’s face it, I’m just too good to you.)
-
Adding Sub-Domains with Nginx
Rather than add somesite.tld, maybe you want some.subsite.tld? Here’s how to set your A record using a DNS manager and the vhost file for Nginx.
-
Add/Delete MySQL Database from Command Line
Need a database? Want to bin an old db? This tutorial shows you how using the terminal command line console whatnot.
-
Configure phpMyAdmin for Nginx to Maintain MySQL
Rather than have to crunch databases via the command line, we can make life easier by adding this splendid tool to manage them.
-
Backup/Export MySQL DB with CLI & mysqldump
Here’s how to backup a database from the command line using the handy mysqldump utility.
-
Import MySQL Database using Command Line
Import data to a new database with this simple mysqldump guide .. great for reinstating an old backed-up db, for instance.
-
Batch Replace/Delete Data in MySQL Database
Change repetitive db data with a single command. Rather than manually find & alter each instance, isolate the lot & update multiple content.
-
LOST a MySQL Password? How to RESET it
Lost your MySQL password? That’s a bit of a bummer .. or it would be if you didn’t have this new password setup guide, huh.
-
Backup or Upload with Secure Copy SCP (Linux to Linux)
Never mind FTP m8! Save time and download/upload your files using encrypted SCP (secure copy), the #1 Linux-Linux file transfer solution.
-
Backup or Upload with PuTTY PSFTP (Windows/Linux)
Equivalent to the above, how to transfer your files if you’re unlucky enough to be running Windows for your local PC. Not that I’m biased.
-
*USEFULLY* Park A Spare Domain with Nginx
Got a spare domain name sat around doing nothing? Put it to some use, have it point its traffic at your primary domain. Here’s the deal ..
-
Password Protect Nginx Web Files/Directories
Maybe you want a hidden website directory, say, for projects, or are developing a site and want it off-limits ’till launch day. Top tip ..
-
Redirect Web Pages with Nginx Rewrite Rule
Here’s the syntax to point a site or blog to another domain. That way, for instance, traffic from a passive site benefits an active one.
-
Nginx Error & Access Logs
Need to troubleshoot some error, or want to find out who’s trying to hack your site? Here’s a start .. those tell-tale logs.
-
Subversion for Easy CMS Updates ie WordPress/Drupal/etc
A brief introduction to install and know about the power of Subversion, the version control system to keep scripts and platforms up-to-date.
-
You Tell Me …
Something missing? Probably. Let me know what you’d like included. And if it’s listed below, shout out anyhow and I’ll try to bump it.
Nginx Admin: In the Works ..
This lot’s marked for addition already:-
- Setup or Edit DNS using Bind
- Network Tools Troubleshooting Guide
- The Comprehensive Permissions Guide
- Configuring Nginx Rewrites
- Custom Website Error Page
- Setting up Cron Jobs
- Rsync for Incremental Remote-to-Local Backup
- Cron & Rsync for Automatic Backup
- Cron & mysqldump for Auto DB Backup
- Safeguard Bandwidth with Hotlink Protection
- Block Access with Nginx’ IP Deny
Got a Question? Want to Comment?
This site has no comments system. We've got a better system!
Please use the link at the top of the post and goto this topic's forum thread:-
- to help build community
- for a superior knowledge base
- to keep info in one place, not diluted between forum & comments.
For those posts ported from Guvnr.com (pre-Feb/2010), archive comments remain.
Handy info from these comments is in the process of being ported to the forum and attributed to the original author.
If you think this idea sucks, let me know.
Thank you.






















News Set Up Unmanaged VPS (4 Newbies) – Part 19: Moving Day! How to Move Your Blog or Site | Web 2.0 Designer July 1st, 2009 at 3:11 am
[...] Read more: Set Up Unmanaged VPS (4 Newbies) – Part 19: Moving Day! How to Move Your Blog or Site [...]
News Set Up Unmanaged VPS (4 Newbies) – Part 19: Moving Day! How to Move Your Blog or Site | Web 2.0 Designer July 1st, 2009 at 3:12 am
[...] See the rest here: Set Up Unmanaged VPS (4 Newbies) – Part 19: Moving Day! How to Move Your Blog or Site [...]
Bob September 2nd, 2009 at 9:38 pm
FYI: On a Mac I see this which is logical since it is a Linux system:
$cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
the_guv September 16th, 2009 at 8:26 pm
@Bob .. cheers for the tip. Course, I run Linux cos i can’t afford a Mac
Yendis September 19th, 2009 at 9:40 pm
Hi Guv, Thanks for the response. I just used that top tip and it works!
However, I am seeing the nginx welcome page. I reckon I should be seeing my uploaded files so I guess something is not right somewhere but where?
The other thing I wanna ask about is ‘create & link any databases and import your data within’. This I know how to do with phpMyAdmin. Have you done a guide to do this with CLI? Do you suggest installing phpMyAdmin on my VPS? Is there a guide for that?
Yendis September 20th, 2009 at 1:17 am
Aah. As I am not using WordPress I sort of skipped part 14. I’ve now used it to guide me in setting up my database. I’m trying to set up phpMyAdmin but it requires me to browser to its directory which I can’t do at the moment. I’m still stuck with the nginx welcome page.
the_guv September 23rd, 2009 at 10:18 am
@Yendis .. dude, keep ploughing thru! Just copy/paste, don’t divert from 1-20, and you can’t go wrong.
Yendis October 10th, 2009 at 5:11 am
Hey Guv,
I’ve been successful in serving a clone of my site on my Linode VPS. The IP I have is 97.107.XX.XXX. I can’t change the nameservers for the main site I want to move myself. I have to instruct the domain registerer. I asked that they ‘change the nameservers to ns1.linode.com, ns2. . . This they seem to have done but the Domain DNS details page now displays:
MX Records
0 mydomain.com 74.54.XXX.XXX
Nameservers
ns2.linode.com 65.19.178.10
ns3.linode.com 75.127.96.10
ns4.linode.com 207.192.70.10
ns1.linode.com 69.93.127.10
WWW verwijzingen
mydomain.com 74.54.XXX.XXX
http://www.mydomain.com mydomain.com
The 74.54.XXX.XXX IP is that of the server I am moving the site from.
I’m pretty sure these settings won’t work.
I reckon I need to tell them to change the old IPs to my new one. Would that be all? Are those IPs for the Linode nameservers correct?
Cheers.
the_guv October 10th, 2009 at 7:48 pm
Hi Yendis,
Well, the NS records are right, for sure (and the order of them is irrelevant too, as far as I know). Maybe this is just a question of a little time for propagation. Hmmn. Well, I’m sure there are other ways to do this but maybe the easiest ..
Setup a dummy DNS zone, as explained in Add a Domain Zone to Your VPS. Call the domain anything-you-like.com and have Linode’s DNS manager set the records for you, as prompted in the options. Then copy the variables generated in the editable summary page to your real zone, and wait for propagation (which is really fast with Linode, their db updates every quarter-hour).
Then again, the way to find your IP, otherwise, is either by checking on the DNS Manager and looking at the page where you edited your reverse DNS setting (you did that in the Postfix setup bit) .. or just by typing ifconfig in the terminal (not ipconfig, that’s Windoze.)
Cloned it huh .. that sounds like another tute-to-go ..
Setup Google Apps Free to POP/IMAP Domains: VPS BIBLE - vpsBible February 10th, 2010 at 5:00 pm
[...] Moving Day! How to Move Your Blog or Site we’ll work through the best procedure for a smooth transition to your new server, be it [...]
the_guv March 5th, 2010 at 6:27 am
Tx to a cracking plugin to sync the bbPress forum to WP comments .. comments are open now.
Post here and your comment is automatically posted in the relevant forum. Post there and vice-versa.
Comments below here have been imported from Guvnr. Bit of a timeline gap so apologies for that.
(Big cheers to Bobrik for wordpress-bbpress-syncronization.)
EASY! Setup DNS Domain Zone & Nameservers: VPS BIBLE - vpsBible April 23rd, 2010 at 4:12 pm
[...] effect. There is an art to getting it right, so your site doesn’t become a white screen. Read Moving Day! How to Move Your Blog or Site for more on [...]
CHEATSHEET Add More Domains with Nginx: VPS BIBLE - vpsBible July 7th, 2010 at 6:29 pm
[...] Upload your new domain’s site files and go check it. If you’re relocating an existing site, you should read Moving Day! How to Move Your Blog or Site. [...]
ADD Nginx Sub-Domains (or WordPress Blogs): VPS BIBLE - vpsBible July 7th, 2010 at 6:29 pm
[...] Upload your sub-domain files and go check it. If you’re moving an existing site, you should read this for a hassle-free relocation. [...]