03 Aug

Moving your Website to Amazon EC2

We recently transitioned our website from a VPS (virtual private server) to the Amazon AWS cloud environment. Benefits include more control of your server and usually less cost. The major drawback is you need to run the server yourself so some basic Unix knowledge is necessary.

The transition itself was very straight forward consisting of the following steps:

  • Purchase Amazon EC2 large instance, this provides enough CPUs and memory to run a full LAMP environment (Linux, Apache, MySQL and PHP). If you don’t need a database then using a medium will work OK.
  • Ensure you provision enough disk space for your software, database and for backups. For a MySQL server you will probably want around 20GB of space to give yourself room for database files and backup files, whereas if you don’t need a database 8GB will be plenty.
  • Install the Zend CE Server, this is the free version of the Zend Server software by Zend. Zend Server CE will install the full LAMP environment rather than installing pieces one at a time. Great for someone new to running their own server. Easy to install using the ‘yum’ application – see http://www.thomasnetworks.net/2011/08/zend-server-ce-centos-5-5-via-yum/ for details.
  • The Zend CE Server comes with phpMyAdmin – you can use this to load a copy of your existing database if needed
  • Add an Elastic IP to your EC2 instance – this will ensure your server’s IP address doesn’t change if you decide to change your EC2 instance type (i.e. upgrade you server). Use the Amazon AWS interface for this.
  • Create a dev.<sitename> address in your DNS pointing to the IP address of Elastic IP. If your current server provides your DNS services you will need to find another provider – I use DNS Made Easy
  • Load your files onto the server, setup Apache and ensure you can access your site through the dev.<sitename> address
  • Test your site including access to the new database if you installed one using the dev.<sitename> address.
  • Ensure the server will also respond to your production server name – usually www.<sitename>. You can not test this fully until cutover.

One tip if you have never run a mail exchanger before is to cut your email over to Google mail – they will run your mail service for you and you can keep your own company email address and it’s free for small businesses with under 10 accounts – see http://www.google.com/enterprise/apps/business/products.html and pricing at http://www.google.com/enterprise/apps/business/pricing.html

To switch over production:

  1. If you don’t care that both servers are up at the same time then change the DNS record for your production server to point to the Elastic IP. It will take 24 to 48 hours for everyone to move to the new server.
  2. If you do care then you’ll want to lower your DNS’s TTL (time to live) value to 5 minutes (300) about a week before cutover. Then when you want to switch turn off your old server, change the IP address of your production server to the new Elastic IP address, and within 5 minutes everyone will be using the new server. Remember to change the TTL back once you’re satisfied with your new server setup.

In either case plan on keeping both servers live for a few weeks after cut over, and once you’re sure nothing is missing you can decommission the old server.

Leave a Reply

Your email address will not be published. Required fields are marked *