Trending News

Blog

How to install Tomcat 7 on Ubuntu, LinuxMint & Debian Easy Guide
Debian

How to install Tomcat 7 on Ubuntu, LinuxMint & Debian Easy Guide 

install Tomcat 7

Apache Tomcat, like the Apache HTTP server, is an open-source web server from the Apache Foundation. It is used to deploy JSP and Servlet applications in Java. We can easily generate a war file and deploy it in Tomcat to deploy an application. 

Table of Contents

In this article, you will learn how to install Tomcat 7 on Ubuntu, LinuxMint & Debian.

Step 1: Verify Java is Installed

First, we must ensure that Java is installed on our system. The first prerequisite for installing Tomcat is JAVA. To see if you already have Java installed on your system, run the command below. Attempt to keep Java up to date by installing the latest version.

				
					$ java -version

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
				
			

Use this link to install Java 8 on Ubuntu if you don’t have it installed.

Step 2: Download Apache Tomcat Archive

Let us download the Apache Tomcat archive file from Apache official site using

				
					http://tomcat.apache.org/download-70.cgi
				
			

or use the following command to download Tomcat 7.0.68 from the Apache server after properly configuring JAVA on your system.

				
					cd /opt
wget http://www-us.apache.org/dist/tomcat/tomcat-7/v7.0.99/bin/apache-tomcat-7.0.99.tar.gz
				
			

After the download is complete, extract the archive file to the /opt directory. This location can be changed to suit your needs.

				
					sudo tar xzf apache-tomcat-7.0.99.tar.gz
sudo mv apache-tomcat-7.0.99 tomcat7
				
			

Step 3: Configure Environment Variables

Configure environment variables before starting Tomcat by adding an entry to the /.bashrc file, so that the system environment can be set when the system boots up with the following command.

				
					echo "export CATALINA_HOME="/opt/tomcat7"" >> ~/.bashrc
source ~/.bashrc
				
			

Step 4: Now Start Tomcat

Once you have completed all of the above steps, run the command below to start Tomcat. It is not necessary to compile the source. As Tomcat starts on port 8080 by default, make sure no other applications are using the same port.

				
					cd /opt/tomcat7
sudo ./bin/startup.sh
				
			

Step 5: Access Tomcat On Browser

The default port for the Tomcat server is 8080. Connect your server to port 8080 and use a web browser to access Tomcat.
				
					http://svr1.yehiweb.com:8080


				
			
installation of tomcat 7 apache server yehiweb
installation of tomcat 7 apache server

Step 6: Create User Accounts

Finally, user accounts must be created in order to secure and access admin/manager pages. In your editor, open the conf/tomcat-users.xml file and paste inside the and /tomcat-users> tags.

				
					# user manager can access only manager section.
<role rolename="manager-gui" />
<user username="manager" password="_SECRET_PASSWORD_" roles="manager-gui" />

# user admin can access manager and admin section both.
<role rolename="admin-gui" />
<user username="admin" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" />
				
			

Step 7: Create Init Script for Tomcat 7

Create a /etc/init.d/tomcat7 init file with the following content.
				
					#!/bin/bash

### BEGIN INIT INFO
# Provides:        tomcat7
# Required-Start:  $network
# Required-Stop:   $network
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Start/Stop Tomcat server
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin

start() {
 sh /opt/tomcat7/bin/startup.sh
}

stop() {
 sh /opt/tomcat7/bin/shutdown.sh
}

case $1 in
  start) start;;
  stop)  stop;;
  restart) stop; start;;
  *) echo "Run as $0 <start|stop|restart>"; exit 1;;
esac</start|stop|restart>
				
			

To configure proper permissions and symbolic links for the init script, run the following commands.

				
					chmod 755 /etc/init.d/tomcat7
update-rc.d tomcat7 defaults
				
			
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on reddit
Share on vk
Share on tumblr
Share on skype
Share on stumbleupon
Share on whatsapp
Share on email

Related posts

Leave a Reply

Required fields are marked *