Tomcat 6 on Ubuntu 12.04

Supposing you don’t want to install the Tomcat version that is packaged on Ubuntu (if you need a differente version), this is what you should do:

Download Tomcat here to your home dir.

Add the Tomcat user and group

$ sudo groupadd tomcat
$ sudo useradd -g tomcat -s /usr/sbin/nologin -M tomcat

Go to /usr/local dir and unzip (beware of the file name, you may have downloaded a different/newer version), give appropriate permissions and create a simlink to ‘tomcat’

$ cd /usr/local
$ sudo tar -zxvf ~/apache-tomcat-6.0.36.tar.gz
$ sudo chown -R tomcat. /usr/local/apache-tomcat-6.0.36
$ sudo ln -s apache-tomcat-6.0.36 tomcat

Check if you can start it:

$ sudo /usr/local/tomcat/bin/

There should be something like this on the screen:

Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar

Open the following addres on your web browser: http://localhost:8080 (or replace localhost with your server name/ip address) and verify that Tomcat started properly (a pretty page should be displayed telling you that you’ve installed Tomcat succesfully, or something like that).

Now shut it down:

$ sudo /usr/local/tomcat/bin/

The same messages that appeared when you started it up should appear again (I know, I know, pretty weird).

Now you can use the following script to start and stop Tomcat. Download it to your home directory and place it at /etc/init.d

$ sudo mv tomcat /etc/init.d

To start/stop as the tomcat user, run the following command (it’s already on the script):

$ sudo su -s /bin/bash tomcat -c /usr/local/tomcat/bin/
Share Button

Leave a Reply