How to configure Tomcat in Ubuntu?

Configuring Tomcat in Ubuntu with Apache server running on it

Login with the root account. Check if java is already installed on the machine. If not, first install java on ubuntu.

Web get the apache-tomcat tar file from the below location

$ cd /tmp
$ wget

Untar the file
$ tar xvzf apache-tomcat-6.0.18.tar.gz

Move the tomcat file to a location of your choice
$ mv apache-tomcat-6.0.18 /usr/local/tomcat

Now, edit the profile setting to add JAVA_HOME setting
$ vi ~/.bashrc

Add the below line and save the file

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

Now restart tomcat

$ /usr/local/tomcat/./

Another way to do this is to setup a shell script in /etc/init.d

$ vi /etc/init.d/tomcat

#Tomcat start, stop, restart

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

case $1 in
sh /usr/local/tomcat/bin/
sh /usr/local/tomcat/bin/
sh /usr/local/tomcat/bin/
sh /usr/local/tomcat/bin/
exit 0

Save the file and given execute permission for the script. Check your path settings for JAVA_HOME and the tomcat file locations to ensure that the script executes as expected.

$ chmod 755 tomcat

Now you can start, stop, restart tomcat as

$ /etc/init.d/tomcat start
$ /etc/init.d/tomcat stop
$ /etc/init.d/tomcat restart

Test if Tomcat is running smoothly by going to


It should show the welcome screen from Apache Tomcat.

Note that Tomcat takes up the port 8080 for its applications by default. You can configure Tomcat to run as several instances as well.


Written by kurinchilamp

Website: http://

Leave a Reply

Your email address will not be published. Required fields are marked *