Tomcat on EC2
A couple of us recently attended a great seminar put on by the folks at SpringSource. They discussed some great strategies for large scale deployment of TC in a sensible and extensible fashion into productions environments. The approach works as well in our dev sandboxes as it does in production, so I’ll be following some of the best practices learned from the folks who know it best.
What do I have and what do I need?
Depending on the AMI you chose, Tomcat may or may not be installed. Some distributions come with TC installed already.
I suggest that you don’t rely on the distribution version of TC since it may be one that has been modified by the creators of the distribution. Better to just go to the source and get the latest and greatest.
One great thing about using TC is that you just download the version of your choice, unzip/untar it, and you’re essentially off to the races.
Preparation
Similarly, many disty’s come with Java installed and they again can be specific to the disty. I always like to make sure we have the latest Sun Java installed. Feel free to use the version of your choice but your mileage may vary. I’m going to be using the Sun Java6 JDK
Over to the terminal window and do:
apt-get install sun-java6-jdk
It will take a while for all this and the dependencies to all load. When it’s complete, you can verify the install by doing:
java –version

Download TC
Let’s go to http://tomcat.apache.org There’s plenty of reading there regarding which version does what which we can leave as an exercise. Let’s grab Tomcat 6.x from the left hand side of the page under Downloads. Scroll down the next page and we have some choices:

If you hover over the tar.gz link, you’ll see the path in your browser:
![]()
Cool. So back over to our terminal window on our EC2 machine.
We’ll do a wget command to get this version:
wget http://www.devlib.org/apache/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz
When it’s completed:

Install TC
Now that you’ve downloaded it, let’s move it to someplace more permanent and untar it.
I’m using /usr/local/tomcat but you can use the location of your choice. One of the beauties of TC is that it has no requirements regarding where you install it and almost no requirements about where you store the various folders within as we’ll learn later.
mv apache-tomcat-6.0.14.tar.gz /usr/local/tomcat
tar xvzf apache-tomcat-6.0.14.tar.gz
We’ve now downloaded TC and installed it to a permanent location. Before we go any further, let’s examine what we have and what it all means.