Categories: UbuntuUbuntu 12.04

How to install tomcat 7 on ubuntu 12.04

Tomcat ( Apache tomcat ) is an open source web application server used to deploy JAVA servlets and JSPs.
This article helps you to install Tomcat 7 on ubuntu 12.04 . This article covers 2 types of installation:- Manual and Apt-get. Manual installation will install the latest version while Apt-get installation will install the repository version.

Install tomcat 7 on ubuntu 12.04

1. Manual installation ( Recommended ).
2. Apt-get installation.

Manual installation

You can install latest version using this method.
Step 1 » Before installing tomcat, install java JDK by typing below command.
krizna@leela:~$ sudo apt-get install openjdk-6-jdk
Step 2 » Download the latest tomcat version from here.
krizna@leela:~$ wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.47/bin/apache-tomcat-7.0.47.tar.gz
Step 3 » Untar the package and move to /usr/local/ folder.
krizna@leela:~$ tar -xvf apache-tomcat-7.0.47.tar.gzkrizna@leela:~$ sudo mv apache-tomcat-7.0.47 /usr/local/
Step 4 » Create a file tomcat747 in /etc/init.d/ and add the below code.krizna@leela:~$ sudo vim /etc/init.d/tomcat747

#!/bin/bash
export CATALINA_HOME=/usr/local/apache-tomcat-7.0.47
PATH=/sbin:/bin:/usr/sbin:/usr/bin
start() {
 sh $CATALINA_HOME/bin/startup.sh
}
stop() {
 sh $CATALINA_HOME/bin/shutdown.sh
}
case $1 in
  start|stop) $1;;
  restart) stop; start;;
  *) echo "Run as $0 <start|stop|restart>"; exit 1;;
esac

This file will create a service named tomcat747 . please change CATALINA_HOME in the code according to your path .
Step 5 » Modify the file permissions.
krizna@leela:~$ sudo chmod 755 /etc/init.d/tomcat747
Step 6 » Choose username and password to manage tomcat and add to /usr/local/apache-tomcat-7.0.47/conf/tomcat-users.xml file in the below format.

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

This code must be within this < tomcat-users > …. < / tomcat-users > Tags
Step 7 » Now start the service .krizna@leela:~$ sudo /etc/init.d/tomcat747 startand type this command to start service automatically during reboot.
krizna@leela:~$ sudo update-rc.d tomcat747 defaults
Step 8 » Now open http://serverip:8080 in your browser. you could see the tomcat main page and use the username and password to see other pages.


That’s it .. you got latest version.

Apt-get installation

You will get repository version using this method.
Step 1 » Install java JDK by typing below command.krizna@leela:~$ sudo apt-get install openjdk-6-jdk
Step 2 » Now Install tomcat 7 along with dependencies using the below command.
krizna@leela:~$ sudo apt-get install tomcat7 tomcat7-docs tomcat7-examples tomcat7-admin
Step 3 » Choose username and password to manage tomcat and add to /etc/tomcat7/tomcat-users.xml file in the below format.

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

This code must be within this < tomcat-users > …. < / tomcat-users > Tags
Step 4 » Now restart the service .krizna@leela:~$ sudo /etc/init.d/tomcat7 restart
Step 5 » Now open http://serverip:8080 in your browser. you could see the tomcat main page and use the username and password to see other pages.


That’s it .. good luck

Disqus Comments Loading...
Share
Published by
krizna

Recent Posts

How to install Visual Studio Code on ubuntu 20.04

Visual Studio Code is a popular code editor which is lightweight and cross platform application.…

4 years ago

How to install MySQL workbench on ubuntu 20.04

MySQL workbench is a GUI tool for managing MySQL database system. It is used by…

4 years ago

How to install Android Studio on ubuntu 20.04

Android Studio is a popular development software used especially for developing android applications. It is…

4 years ago

How to install google chrome on ubuntu 20.04

Google chrome is a most popular web browser developed by google. It was developed to…

4 years ago

How to install Zoom on ubuntu 20.04

Zoom is a popular video conferencing software. It is commonly used for conducting online meetings,…

4 years ago

How to install TeamViewer on ubuntu 20.04

TeamViewer is a popular application for desktop sharing and remote control. It is available for…

4 years ago