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.gz
krizna@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 start
and 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
this URL http://apache.osuosl.org/tomcat/tomcat-7/v7.0.47 doesn’t work… use
http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.47/bin/apache-tomcat-7.0.47.tar.gz
this URL http://apache.osuosl.org/tomcat/tomcat-7/v7.0.47 doesn’t work… use
http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.47/bin/apache-tomcat-7.0.47.tar.gz
Really thanks for this post .
great work.. it works in the first attempt .
Really thanks for this post .
great work.. it works in the first attempt .