UPDATE: This post was originally created in June 2010. There are much more convenient, one-click installs for Railo on EC2 now.
(Whooh! That’s a long-winded title!)
I’ve become a big fan of Railo as an alternative to Adobe Coldfusion Server, particularly because of its ability to easily connect to Amazon S3. I love what Amazon S3 offers in terms of inexpensive file storage, and our latest project, TheClientSpace.com, takes full advantage of the Railo/S3 feature.
It’s been quite a learning experience, however, in getting the right setup together for deployment of Railo on Amazon EC2, mainly because a) I’m still pretty new to understanding Linux as a whole, and b) I really want my files to be easily backed up – which can be time consuming if storing your Web site files on the main EC2 drives.
I’ve written up this simple guide to explain how I have currently set up Railo on Ubuntu using Tomcat, on Amazon EC2 with EBS volumes to simplify the backup of your website’s files and database by using the EBS snapshot feature.
If you’re new to EC2 and are having trouble understanding some of the steps I’ve written here, please contact me and I can help you out.
Step 1: Launch Your Instance, Attach Your EBS Volumes
For this installation, I’m using Ubuntu Server 9.10. For those of you looking for exactly the image I used, it’s alestic/ubuntu-9.10-karmic-base-20090623.manifest.xml.
Launch your instance. Then create your EBS volume and attach it to your instance. In this example, I’m creating a 5GB EBS volume and attaching it as /dev/sdf.
Connect to it via SSH. I’m on a PC, so I am using PuTTY.
The first thing we do, now that we’ve logged in, is to initialize and mount/connect your drive.
mke2fs -F -j /dev/sdf
mount /dev/sdf /ebs
The drive is now mounted as the folder /ebs.
Now we’re going to pre-emptively create the Apache folders and MySQL folders on our EBS volume. This eliminates any confusion as to where the files are actually going once we start uploading our application and installing MySQL.
mkdir -p /ebs/var/lib/mysql
ln -s /ebs/var/lib/mysql /var/lib
mkdir -p /ebs/var/www
ln -s /ebs/var/www /var
Now the hard part is done! From this point on, our MySQL DB files and website application files will rest on our EBS volume – making it for easy backup via the EBS snapshot feature.
Step 2: Update Ubuntu, Install LAMP/phpMyAdmin
Before installing anything, Ubuntu needs to be updated:
sudo apt-get update
sudo apt-get upgrade
Now we can install the LAMP server.
sudo tasksel install lamp-server
Make sure to remember the passwords you created during this process! I say this from experience!
I like to use .htaccess to customize my search-engine-friendly links, so I’ll add that now and restart Apache.
Apache, PHP and MySQL are now set up. The next step is to install phpMyAdmin.
sudo apt-get install phpmyadmin
The server is now ready for Railo!
Step 3: Install Railo and Set Your Mapping
Before we get started, I’d like to thank Jordan Michaels for creating this great, easy-to-use Railo installer. I also want to thank the guy that wrote this post for helping me get as far as I did. Now let’s get it:
chmod 777 railo-3.1.2.001-pl0-linux-installer.bin
That link above might change as the versions change over time.
Take note – when going through the install process, make sure you follow the instructions carefully as there are some specific Ubuntu settings that need your attention.
Let’s make sure Railo works. Browse over to your server’s public URL: ec2-[YOUR_PUBLIC_DNS].compute-1.amazonaws.com/railo-context/admin/web.cfm
If it works, excellent! Log in so that we can create the mapping to the Apache folder.
In your Railo Web Administrator, click on the Mappings link. Add the mapping for “/” as “/var/www” as shown in the image below.
Press the “Save” button, and you’re ready! Now, I would say the only downside to this last step is that it’s not ideal if you want to use multiple virtual hosts. I’d love to learn from you how it would be possible to do that with what’s already been done here.
Now that the basic Railo setup is complete, it would be a good idea to create a regularly scheduled snapshot of your EBS volume, which holds all of the files in your /var/www folder and /var/lib/mysql folder. The one snapshot will back up all of your vital files! Also, you may want to consider creating a backup of your entire server setup using the Amazon AMI tools.
Comments? Questions? Write them out below or contact us.