Monday, August 15, 2016

How To Install Tomcat in Ubuntu

Install Oracle's JDK

Install Java, see here

Set the JAVA_HOME, CATALINA_HOME and PATH environment variables

The JAVA_HOME variable is used by Java Servers such as Tomcat and JBoss, and by build tools such as Ant and Maven, and by other Java applications.

The CATALINA_HOME variable is required by when running Tomcat from command line to locate the files stored in $CATALINA_HOME/conf and $CATALINA_HOME/logs directories.

To set user environment variables edit the ~/.profile:

max@ubuntu-host:~$ nano ~.profile

Append the following lines to the ~.profile file:

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export CATALINA_HOME=/opt/apache-tomcat-8.0

Tomcat Installation

To Download the latest version of tomcat from apache. Choose the binary distribution tar.gz. Copy the destination link and past it in the terminal after the wget command. You shoul get something alike:

~$ wget

Untar the binary archive:

~$ tar -xvf apache-tomcat-8.0.38.tar.gz

Copy the folder to /opt directory:

~$ sudo cp -R apache-tomcat-8.0.38 /opt/apache-tomcat-8.0

Change owner user and owner group of the /opt/apache-tomcat-8-0 directory:

~$ sudo chown max:max -R /opt/apache-tomcat-8.0

Finally, you get an /opt/apache-tomcat-8.0 directory and the its owner is the user logged in:

max@ubuntu-host:/opt$ ls -l
total 18
drwxrwxr-x 9 max      max      4096 Aug 15 17:10 apache-tomcat-8.0
drwxrwxr-x 8 max      max      4096 Aug 15 15:31 eclipse-jee-neon
drwxr-xr-x 3 root     root     4096 Jul 31 09:57
drwxr-xr-x 3 root     root     4096 Jul 30 21:22 google
drwxr-xr-x 4 root     root     4096 Aug  8 16:19 sublime_text

Common Tomcat Commands

To start tomcat, type on the shell:


To stop tomcat, type on the shell:


To read the log file:

cd /opt/apache-tomcat-8.0/log
~$ tail -f catalina.out

Test Tomcat installation by pointing your browser to: http://localhost:8080

Manager Web Application

The Manager App is an application that comes with Tomcat and allows you to start, stop, reload and undeploy web applications installed in Tomcat

To allow the access to the Manager App, you must add a manager user to the tomcat users configuration file.

Edit the file /opt/tomcat-8/conf/tomcat-users.xml, and add the following two lines:

<role rolename="manager-gui"/>
<user username="manager" password="password" roles="manager-gui"/>

No comments :

Post a Comment