questions - Question:how to Install Tomcat 7 on Ubuntu 12.04

Apache has officially launched version 7.0 of the servlet container for Java applications, Tomcat. Major changes in this version, you can highlight support for Servlet 3.0 and JavaServer Pages 2.2.

Install JDK
See this post: Install JDK 6 update 23 in Ubuntu 10.10


The first thing to do is download the package "apache-tomcat-7.0.6.tar.gz" from the NEXT link [tar.gz]

Now unpack it with the following command:

    tar xvzf apache-tomcat-7.0.8.tar.gz

Then we let in a more appropriate directory, in our case in / usr/share/tomcat7, but can be in any directory. We do this with the command:

    sudo mv apache-tomcat-7.0.8/ /usr/share/tomcat7

Now we define the environment variables JAVA_HOME and JRE_HOME. This file is in the "environment" in / etc. Command to edit the file:

    sudo gedit /etc/environment

Here we record the routes where we have installed Java in my case this is as follows:

    PATH="...(other path):$JAVA_HOME:$JRE_HOME"

IMPORTANT: Verify the routes where they have installed Java.

I have had some problems in defining these environment variables, as sometimes tomcat does not recognize, but a surefire way of recognizing that tomcat is to define the file paths inside ""located in tomcat7/bin. To modify this file use the command:

    sudo gedit /usr/share/tomcat7/bin/

Now just insert the JAVA_HOME and JRE_HOME after the first line, so the file is as follows:

    # Licensed to the Apache Software Foundation (ASF)...

Now let's configure Tomcat users, this is done in the file "tomcat-users.xml"directory tomcat7/conf. Command to edit the file:

    sudo gedit /usr/share/tomcat7/conf/tomcat-users.xml

Unlike previous versions where the administrator should own role "manager" now it should be "manager-gui"to operate on the web administration tomcat7. The file would be as follows:

Now you should be all ready to try tomcat7.

First we must lift the server with the following command:

    sudo /usr/share/tomcat7/bin/

With this we get the following output on console:

    Using CATALINA_BASE: /usr/share/tomcat7
    Using CATALINA_HOME: /usr/share/tomcat7
    Using JRE_HOME: /usr/local/jdk1.6.0_20/jre
    Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar

Verify that the JRE_HOME is where we define.

Now open your web browser and type the following url:

So we get the following page:

If we enter the administration Tomcat Manager we click on the menu or directly at URL:

Here we ask the user data from previous record in mind tomcat-users.xml.

I recommend testing the sample to make sure everything works ok, they are in the section "Miscellaneous" from the side menu or at the URL:


Start server:

    sudo /usr/share/tomcat7/bin/

Stop server:

    sudo /usr/share/tomcat7/bin/

Automatic Starting

To make tomcat automatically start when we boot up the computer, you can add a script to make it auto-start and shutdown.

sudo gedit /etc/init.d/tomcat7

Now paste in the following:

# Tomcat auto-start
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/

case $1 in
sh /usr/share/tomcat7/bin/
sh /usr/share/tomcat7/bin/
sh /usr/share/tomcat7/bin/
sh /usr/share/tomcat7/bin/
exit 0

You’ll need to make the script executable by running the chmod command:

sudo chmod 755 /etc/init.d/tomcat7

The last step is actually linking this script to the startup folders with a symbolic link. Execute these two commands and we should be on our way.

sudo ln -s /etc/init.d/tomcat7 /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat7 /etc/rc2.d/S99tomcat

Tomcat should now be fully installed and operational. Enjoy!

sudo /etc/init.d/tomcat7 restart

asked Sep 13, 2013 in LINUX by anonymous
edited Sep 12, 2013
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.