Skip to main content

How To Install Apache Tomcat on Ubuntu

Apache tomcat is a Java based application server released by the Apache Software Foundation. It is a web server and a servlet container for Java web applications.

Setup

Tomcat installation on a virtual private server is relatively easy. Its single required dependency is Java and this tutorial will include a step on how to install that platform.
You do need to have a user with sudo privileges for this tutorial.


There are two basic ways to install Tomcat on Ubuntu:

  • Install through apt-get. This is the simplest method. 
  • Download the binary distribution from the Apache Tomcat site.

Step One—Install Through apt-get

 
The first thing you will want to do is update your apt-get package lists:
 
sudo apt-get update 

The most recent version of Tomcat is 7, and it can be easily downloaded through apt-get 

sudo apt-get install tomcat7
 
Install additional packages  

sudo apt-get install tomcat7-docs tomcat7-admin tomcat7-examples
 
 

Step Two—Install Through Binary Distribution

To download tomcat from their site, copy the link for the tar.gz package under the “Core” section and begin the download. You will get a link that originates from one of Apache’s many mirrors, making the command look mostly like this (although coming from a different site).

wget http://mirrors.ispros.com.bd/apache/tomcat/tomcat-7/v7.0.55/bin/apache-tomcat-7.0.55.tar.gz

After the download completes, untar the file.

tar xvzf apache-tomcat-7.0.29.tar.gz
 
We first see the  tomcat directory structure
 
here each folder uses following purpose.
bin -  It contains all binary and script files for running tomcat.
lib - contains all shared libraries used for tomcat
conf - contains configuration information like which port tomcat can bind , etc...
logs - it contain all logging details
temp - this folder tomcat used for temporary files purpose
webapps - this folder is very important. here we put all application war files.
work - If application contain any jsp then jsp is translated and converted into servlet its stores here.


When we run Tomcat, it uses 5 environment variables. They are:
  • CATALINA_HOME
  • CATALINA_BASE
  • CATALINA_TMPDIR
  • JRE_HOME/JAVA_HOME
  • CLASSPATH

In the above list, CATALINA_HOME and JAVA_HOME are mandatory environment variables. All others are optional and can be calculated using CATALINA_HOME.
CATALINA_HOME – this environment variable should point to tomcat base folder, where tomcat binary are  installed/extracted. so based on CATALINA_HOME we can get bin and lib folder
CATALINA_BASE – If we not specified then CATALINA_HOME value is set. This variable pointed to configuration and webapps folder. Based on this variable server uses conf, logs, temp, webapps, work folders.


Step Three—Configure .bashrc

 In order to start Tomcat, we need to add it as an environment variable in the /.bashrc file.

sudo nano ~/.bashrc
 
You can add this information to the end of the file:
export JAVA_HOME=/usr/lib/jvm/default-java
export PATH=$JAVA_HOME/bin:$PATH 
export CATALINA_HOME=~/path/to/tomcat
 
Save and exit out of .bashrc. You can make the changes effective by restarting the bashrc file.

. ~/.bashrc
 

Step Four—RUN

Tomcat is now installed and configured on our virtual servers. However, it is not yet activated.

The final step is to activate Tomcat by running its startup script:

$CATALINA_HOME/bin/startup.sh
 
Once that runs, Tomcat is up and ready on port 8080.
You can visually verify that Tomcat is working by accessing your server page at your_IP_address:8080.

It should look like

Tomcat Installation

Let's take a look at the Web Application Manager, accessible via the link or http://your_ip_address:8080/manager/:

tomcat manager

 
 



 

 

Comments

Popular posts from this blog

How to install play framework

Prerequisites To run the Play framework, you need JDK 6 or later . If you are using MacOS, Java is built-in. If you are using Linux, make sure to use either the Sun JDK or OpenJDK (and not gcj, which is the default Java command on many Linux distros). If you are using Windows, just download and install the latest JDK package. Note, Java 7 pre update 9 on MacOS has a bug that causes problems with futures and iteratees, including making large file uploads hang. If using Java 7 on MacOS, make sure you are using the latest version. Be sure to have the java and javac commands in the current path (you can check this by typing java -version and javac -version at the shell prompt). Download the binary package Download the latest Play standalone distribution and extract the archive to a location where you have both read and write access. (Running play writes some files to directories within the archive, so don’t install to /opt , /usr/local or anywhere else you’d need s...

Java HotSpot VM Settings

The following JVM parameters are recommended: -Djava.awt.headless=true  -Dfile.encoding=UTF-8  -server  -Xms512m  -Xmx1024m  -XX:NewSize=256m  -XX:MaxNewSize=256m  -XX:PermSize=256m  -XX:MaxPermSize=256m  -XX:+DisableExplicitGC -Djava.awt.headless=true Headless mode is a system configuration in which the display device, keyboard, or mouse is lacking. Sounds unexpected, but actually you can perform different operations in this mode, even with graphic data. -server The JDK includes two flavors of the VM -- a client-side offering, and a VM tuned for server applications. These two solutions share the Java HotSpot runtime environment code base, but use different compilers that are suited to the distinctly unique performance characteristics of clients and servers. These differences include the compilation inlining policy and heap defaults. Although the Server and the Client VMs are similar, the Serv...

How to install Oracle JDK on Ubuntu from repository

This package provides Oracle Java JDK 7 (which includes Java JDK, JRE and the Java browser plugin). However, you can't only install Oracle JRE - the PPA only provides the full Oracle JDK7 package. To install: sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-jdk7-installer And to uninstall: sudo apt-get remove oracle-jdk7-installer And to verify your installation: java -version java version "1.7.0_51" Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode) And to verify the web browser installation: http://java.com/en/download/installed.jsp Verified Java Version Congratulations! You have the recommended Java installed (1.7.0_51). And to update: If for some reason, the Java version in use is not 1.7.0, you can try to run the following command: sudo update-java-alternatives -s java-7-oracle To Install and Set in environment variable: To...