Tryst with EC2
Today, we successfully hosted our corporate website (www.deerwalk.com) in Amazon EC2. Amazon EC2 is the premier service in cloud computing and given the excitement around cloud computing these days, we wanted to give it a try.
Before we started, we googled for similar prior experiences and we found these sites extremely helpful:
· How We Built a Web Hosting Infrastructure on EC2 (http://www.mikebrittain.com/blog/2008/07/19/web-hosting-on-ec2/ )
· Running Drupal website in EC2 (www.sunsetlakesoftware.com/2008/09/13/running-drupal-website-amazon-ec2)
· Web Site of Rajiv Pant (http://www.rajiv.com/blog/2008/02/04/amazon-ec2/)
· Install and Configure FTP Server in Amazon EC2 instance (http://linuxadminzone.com/install-and-configure-ftp-server-in-amazon-ec2-instance/)
We signed up for an Amazon AWS account. The next was to create and start an EC2 instance. Amazon provides a management console (http://console.aws.amazon.com) for this. But we found the services and user interface provided by RightScale (www.rightscale.com) much easier. RightScale allows you to easily set up and control EC2 instances. In fact, it is so easy to use that in 5 minutes we had our EC2 instance running. All you need to do is simply select a suitable server template from a number of server templates RightScale provides. Server templates consist of a base image that contain a light-weight Linux installation and some scripts that help customize the image's configuration. In our case, we went for LAMP v4 Developer server template. This template sets up an EC2 instance with CentOS, Apache, PHP 5.2.4 and MySQL 5.0.45.
Once the instance was running, we installed a FTP server to transfer website content to the instance. For that, we connected to the instance through SSH console and executed following command.
yum install vsftpd
Many FTP clients nowadays operate in passive mode, and by default, passive mode is not enabled in VSFTP, so we had to enable passive mode by adding following lines in vsftpd.conf file:
pasv_enable=YES
pasv_min_port=1024
pasv_max_port=1048
pasv_address=<IP of the EC2 instance>
Note that the pasv_address field demands an IP address. However, IP of an EC2 instance is not static i.e. if the machine gets rebooted, the IP it gets next time won’t be same as the one it previously had. But, no need to worry! That’s where the Elastic IP comes in handy. Amazon’s new Elastic IP (EIP) addresses allow users to allocate an IP address and assign it to an instance of their choice.
Next, we opened ports in the instance to support passive mode. For this, we first installed and configured EC2 tool.
mkdir ~/.ec2/ec2-tools
cd ~/.ec2/ec2-tools
wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
unzip ec2-api-tools.zip
Next, we configured environment variables to tell where the tool is and who we are:
export EC2_HOME=~/.ec2/ec2-tools/ec2-api-tools-1.3-34128
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=~/.ec2/keys/pk-K2TTWYYQYSS2BMTINPK2B3HNCN77CYPG.pem
export EC2_CERT=~/.ec2/keys/cert-K2TTWYYQYSS2BMTINPK2B3HNCN77CYPG.pem
With these operations, we could now open the required ports using ec2-authorize command:
ec2-authorize default -p 20-21
ec2-authorize default -p 1024-1048
‘default’ is the name of security group we had. We were now able to restart FTP server and connect using an FTP client:
/etc/init.d/vsftpd restart
However, we still got an error message ‘500 OOPS: vsf_sysutil_recv_peek’ trying to connect using FireFTP. The solution we found from http://linuxadminzone.com/ftp-error-500-oops-vsf_sysutil_recv_peek-while-connecting-to-vsftpd/ was loading compatibility module.
modprobe capability
This solved our problem. After restarting, we were now able to connect to the server and to transfer our website contents to the document root of EC2 instance. Upon restarting the httpd service, our site was browse-able using IP address.
Next we made our domain name (deerwalk.com) point to our machine in the cloud. This can be done by simply modifying an A record of your domain. Update the A record value with your instance’s Elastic IP and your domain will now point to the correct IP for that server instance.


In order to comment on blog entries, you must be a registered user of Deerwalk. If you haven't already registered, you can request an account. If you have one then login