Today I’m going to explain how to install Apache Tomcat on a Linux box. We should have a JDK already installed on the box. If that is not the case it can be downloaded from Sun website.
Now we download Tomcat from the website. Once downloaded we will download and install it into the /opt directory. We have to create the tomcat user.
$ sudo useradd -g tomcat -d /home/tomcat tomcat
$ sudo passwd tomcat
Now we have to define the $JAVA_HOME and $CATALINA_HOME variables. In /home/tomcat/.bashrc add the following:
export JAVA_HOME=/opt/java
export CATALINA_HOME=/opt/tomcat
Now change the ownership of /opt/tomcat directory, which is where we downloaded tomcat previously.
$ sudo chown -R tomcat:tomcat /opt/tomcat
We are now ready to start Tomcat. As tomcat user type:
$ /opt/tomcat/bin/startup.sh
If everything went well you shall now see tomcat process running.
tomcat@debian: /opt/tomcat/bin $ ps auxwww | grep -i java | grep -v grep
tomcat 6618 0.3 1.3 1064972 48260 pts/0 Sl 15:51 0:03 /opt/java/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/tomcat/endorsed -classpath /opt/tomcat/bin/bootstrap.jar -Dcatalina.base=/opt/tomcat -Dcatalina.home=/opt/tomcat -Djava.io.tmpdir=/opt/tomcat/temp org.apache.catalina.startup.Bootstrap start
tomcat@debian: /opt/tomcat/bin $
Now let’s see Tomcat on a browser. Hit http://localhost:8080/ and you shall see a page as the one below.