Create Your Instance
Before you create an Amazon EC2 instance, I’d like to recommend Digital Ocean’s $5/mo. fast SSD servers. They make a great choice for hosting your email.
Create an EC2 Server Instance
Now that you have an account, you can log in to the AWS Console to create your new virtual server. Click the EC2 link shown in the dashboard below:
Choosing Between a Micro or Small Instance
If you are only running email for yourself, a micro instance will likely work well for you. If you’re new to AWS, you should be able to run your server in their free usage tier for one year. If you buy a three year reserved micro instance for $100, you can reduce the total monthly fee to $6.44. With a micro instance, you’ll need to set up a swap file (described later) which can generate some minor additional costs and should occasionally be monitored.
If you think you’ll be running email accounts for a number of users, you may want to start with a small instance, which costs $43.92 monthly. If you purchase a three year reserved small instance for $257, it can be reduced to $7.13 monthly (total adjusted monthly rate of $15.79). Read more about pricing and estimating costs.
Click the Launch Instance button shown below to start the create instance wizard. If you do not expect significant web mailbox usage, select an Ubuntu 12.xx (64 bit) Micro instance.
[info_box]Choose the server name you would like to use. The screenshots below say “wordpress” – but for this tutorial, consider using “mailbox”, or any name you choose.[/info_box]
When you reach the page for Configure Firewall, add a security rule to allow HTTP traffic on port 80.
During the process, the wizard will download a private key to your computer’s Downloads directory.
Login Remotely to Your Server Instance
Now, your instance is ready for you to login remotely via SSH. Open Terminal on your computer. Move the downloaded key to your SSH key directory and set the permissions:
mv ~/Downloads/mailbox.pem ~/.ssh chmod 400 ~/.ssh/mailbox.pem
Copy the URL for the instance from the console e.g. ec2-75-101-173-192.compute-1.amazonaws.com (see below):
From Terminal, try to connect via SSH:
ssh -i ~/.ssh/mailbox.pem firstname.lastname@example.org
If you’re using Windows, you’ll need to use PUTTY to connect.
If you still have trouble, you can connect through Amazon’s Console on the EC2 Instance list:
It should look something like this when you connect:
Set Up an Elastic IP Address
Now, it’s time to associate a public IP address with your instance so that you can map your domain name e.g. yourdomain.com to your mail server. From the EC2 Dashboard left sidebar, click on Elastic IPs. Then, click Allocate New Address. Amazon provides one free Elastic IP per running instance.
As shown below, you’ll then have to associate the new elastic address with the instance you created.
The address with which you remotely login via SSH will now have changed to reflect your elastic IP address (replace the x’s with your new elastic IP):
ssh -i ./mailbox.pem email@example.com
This may also work:
ssh -i ./mailbox.pem firstname.lastname@example.org
Please feel free to post corrections, questions or comments below. You can also follow me on Twitter @reifman or email me directly. If this tutorial helped you, please share it on Twitter.