• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Tomcat 7 Server on Ubuntu, Debian and LinuxMint

Written by Rahul, Updated on December 25, 2019

Apache Tomcat is a opensource webserver product of Apache Foundation like Apache HTTP server. It is used for deploying Java Servlet and JSP applications. To deploy an application in Tomcat we can simply create a war file and deploy them. For more details about you can visit apache official site http://tomcat.apache.org/ .

This article will help you to install tomcat 7 on Ubuntu, Debian and LinuxMint systems.

Step 1 – Verify JAVA

First, we need to make sure that we have installed java on or system. JAVA is the first requirement of tomcat installation. Use the following command to check if you have java installed already on your system. Try to keep java up to date with 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)

In case you do not have java installed use link: Install JAVA 8 on Ubuntu

Step 2 – Download Tomcat 7 Archive

After configuring JAVA properly on your system, let’s download 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 Apache server.

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

After competed download extract archive file in /opt directory. You may change this location as per your setup.

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

Step 3 – Setup Environment Variable

Before starting Tomcat, Configure environment variables by adding an entry in the ~/.bashrc file, So that the system environment can set on system bootup with the following command.

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

Step 4 – Start Tomcat

After completing all the above configuration, Let’s use the below command to start Tomcat. There is no need to compile its source. Tomcat by default start on port 8080, So make sure no other application using the same port.

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

Step 5 – Access Tomcat

Tomcat server works on port 8080 default. Access tomcat on a web browser by connecting your server on port 8080.

 http://svr1.tecadmin.net:8080 

Install Tomcat 7.0

Step 6 – Setup User Accounts

Finally we need to create user accounts to secure and access admin/manager pages. Edit conf/tomcat-users.xml file in your editor and paste inside <tomcat-users> </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 Tomcat7 Init Script

Create a init file /etc/init.d/tomcat7 using 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 "; exit 1;;
esac

Now execute following commands to set proper permissions and symbolic links for init script.

chmod 755 /etc/init.d/tomcat7
update-rc.d tomcat7 defaults

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

5 Comments

  1. Avatar Andres Reply
    September 4, 2020 at 8:26 pm

    This is an amazing guide. I found others which where just confusing and didn’t achieve the objective. Thank you so much!

  2. Avatar Himanshu Reply
    December 28, 2017 at 2:39 pm

    Thanks.

  3. Avatar AEI Reply
    April 12, 2016 at 7:13 am

    I don’t know the servername. Where did you get it from?

  4. Avatar sara Reply
    December 2, 2015 at 11:37 am

    Thank you so much !

  5. Avatar rafa Reply
    October 6, 2014 at 5:33 pm

    Thank you so much

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy