Server Migration

OK, so not really server migration, but a bunch of things that have previously helped in server migration projects.

Migrating Apache

Problem: We want to move our services to a new server, but the old server still has to be there for other virtual hosts. We could just remove the virtual host from the server and hope that all the visitors find the new server, but DNS can take a while to propagate around the world, so we don't want to run into the situation where some visitors hit a broken link.

Solution: The solution requires playing around with the DNS and some apache configuration. For example, let's consider moving from the existing server to a new server. Once the new server has been set up and configured with all the correct data, we need to bring it to production. The procedure that has worked is:

  • Set up a DNS entry for the new server
  • Test from lots of places that the DNS change has been propagated. As this is a new DNS entry and not a modification to an existing one, there should be no caching delay.
  • Make sure that the ServerName and ServerAlias for this VirtualHost on the new server allow apache to respond to both names (www and new).
  • On the old server ( replace the apache config with a redirect instruction:

RewriteEngine On
RewriteRule ^.*${REQUEST_URI} [R=301,L]
  • Restart apache on the old server
  • Update the DNS to point at the new server

At this point (hopefully) most requests will be directed directly to the new server. Any requests that find the wrong IP address because the DNS has been cached somewhere will hit the old server, but instead of being served pages from the old server, they will be redirected to the new server via its alternate DNS name.

You can now monitor the logs on the old system, and when no more requests are seen on that box, the VirtualHost configuration can be dropped.


This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies.