Monday, August 25, 2008

Installing Tomcat 6 on Ubuntu

Installing Tomcat 6 on Ubuntu

If you are running Ubuntu and want to use the Tomcat servlet runner, Some times the apt will not work correctly. You can try the following method it will work.

Before you installing Tomcat you must install Java. I would assume if you are trying to install Tomcat you've already installed java, otherwise install Java as per my previous posting. If you aren't sure about your Java installation, you can check with the dpkg command like so:

dpkg --get-selections | grep sun-java

This will give you this output if you already installed java:

sun-java6-bin install
sun-java6-jdk install
sun-java6-jre install


Now we'll download and extract Tomcat from the apache site.


tar xvzf apache-tomcat-6.0.18.tar.gz

The best thing to do is move the tomcat folder to a permanent location. I chose /usr/local/tomcat, but you could move it somewhere else if you wanted to.

sudo mv apache-tomcat-6.0.18 /usr/local/tomcat

Tomcat requires setting the JAVA_HOME variable. The best way to do this is to set it in your .bashrc file. You could also edit your file if you so chose.

The better method is editing your .bashrc file and adding the bolded line there. You'll have to logout of the shell for the change to take effect.

vi ~/.bashrc

Add the following line:

export JAVA_HOME=/usr/lib/jvm/java-6-sun

At this point you can start tomcat by just executing the script in the tomcat/bin folder.

No comments: