I am have a small website that we want to deploy to Amazon EC2. The reason is that it is cheaper than most other VPS systems, and we want to have completely custom configuration so a shared host is not a possibility. Also, the option to scale to a bigger server with the same images is one of the reasons of going for EC2.
Because we start with a t1.micro instance we will use EBS booted instances (x64_64). Our operating system of choice is Ubuntu Server. We don't compile any packages ourselve, sticking to stable packages from the repositories.
All our webserver data is stored on another EBS data volume.
Now the question: How can we best deploy our webserver, while keeping things up to data.
The options I have considered so far:
- Making our own image with the all software we need installed.
- Disadvantage: we have to regularly update the image to have a security updated image when we restart a server. Also, when we switch to a new version of the distribution we have to install everything againg.
- Advantage: there is no time needed when starting the server for any installation procedures
- Using standard Ubuntu Images, and on startup install all servers and copy all non-standard configuration files from the data disk
- Disadvantages: Startup time takes longer, possibly things can go wrong with installation so error-prone
- Advantages: New distribution, or updated images can be used very easily
What is the best way to do it? Are there any good options I missed, or are there any other aspects to my options that I didn't consider.
We use Fabric and libcloud to write python scripts that can call api's to spin up a server, install all the necessary software, and change configurations. It takes slightly longer every time we spin up a server than if we had a disk image, but we think the simplicity of not having to build lots of images is much better.
Make sure all these files live in your VCS (including config files) so you can essentially use that as documentation for what your configuration looks like. Then spinning up a new server can be as simple as
Check out Chef and the hosted service from OpsCode. Chef allows you to automate your deployment and configuration. The chef-client runs on the server as a daemon and can upgrade packages for you, if you wish.
Fabric is great too, we use it mostly for manipulating live servers.
I created my own AMI that already has the LAMP stack and all applications installed. I keep track of any changes and then when I have enough I update the image. I have the apache, mysql, and php configuration files and mysql databases symlinked to the EBS. This allows me to not have to track those changes and they are captured when I attach a current snapshot to the new instance.