Install Apache Tomcat on Ubuntu Server

Apache Tomcat

Apache Tomcat (or simply Tomcat, formerly also Jakarta Tomcat) is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a "pure Java" HTTP web server environment for Java code to run in. In the simplest config Tomcat runs in a single operating system process. The process runs a Java virtual machine (JVM). Every single HTTP request from a browser to Tomcat is processed in the Tomcat process in a separate thread.

Apache Tomcat includes tools for configuration and management, but can also be configured by editing XML configuration files.

OpenJDK

OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java Platform, Standard Edition (Java SE). It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GNU GPL) with a linking exception. Were it not for the GPL linking exception, components that linked to the Java class library would be subject to the terms of the GPL license. OpenJDK is the official Java SE 7 reference implementation.

Apache Tomact Official Website tomcat.apache.org

OpenJDK Official Website openjdk.java.net

Install OpenJDK

$ sudo apt-get update
$ sudo apt-get install openjdk-7-jre

Verify Installation

$ java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

Set JAVA_HOME Environment Variable

Add in ~/.bashrc

$ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/

Download & Install Apache Tomcat

$ wget http://apache.tradebit.com/pub/tomcat/tomcat-8/v8.0.5/bin/apache-tomcat-8.0.5.tar.gz
$ sudo tar xvzf apache-tomcat-8.0.5.tar.gz
$ sudo mv apache-tomcat-8.0.5 /usr/local/tomcat
$ sudo chmod -R 755 /usr/local/tomcat

Set Apache Tomcat Automatically Run at System Startup

$ sudo vim /etc/init.d/tomcat

Content

# Tomcat server auto-start script

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/

case $1 in
start)
sh /usr/local/tomcat/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/bin/shutdown.sh
sh /usr/local/tomcat/bin/startup.sh
;;
esac

exit 0

Set Executable Permissions

$ sudo chmod 755 /etc/init.d/tomcat
$ sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
$ sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

Start Apache Tomcat

$ sudo sh /usr/local/tomcat/bin/startup.sh
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:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

Apache Tomcat Administrator Account Settings

$ sudo vim /usr/local/tomcat/conf/tomcat-users.xml 

Add following code before

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

Restart Apache Tomact Service

$ sudo service tomcat stop
$ sudo service tomcat start

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 this.

Install Apache Tomcat on Ubuntu Server

0.00 avg. rating (0% score) - 0 votes