How to install tomcat 7 on linux ubuntu

Hello friend in this tutorial I will tell you how to setup Tomcat7 in linux. The linux which I used to setup tomcat7 is ubuntu 12.04. 

a) Installing tomcat7 server on ubuntu 12.04 using “apt-get” 
 1. To install the Tomcat server on your machine, just type the following command in Terminal prompt –

sudo apt-get install tomcat7          

This will install a Tomcat server on your machine.

2. To install Tomcat documentation : The tomcat7-docs package contains Tomcat documentation, packaged as a webapp that you can access by default at http://yourserver:8080/docs. You can install it by entering the following command in the terminal prompt:

sudo apt-get install tomcat7-docs

3.To install Tomcat examples webapps : The tomcat7-examples package  webapps that can be used to test or demonstrate Servlets and JSP features, which you can access them by default at http://yourserver:8080/examples. You can install them by entering the following command in the terminal prompt:

sudo apt-get install tomcat7-examples

4.Tomcat administration webapps : The tomcat7-admin package contains two webapps that can be used to administer the Tomcat server using a web interface. You can install them by entering the following command in the terminal prompt:

sudo apt-get install tomcat7-admin

The first one is the manager webapp, which you can access by default at http://yourserver:8080/manager/html. It is primarily used to get server status and restart webapps.

Access to the manager application is protected by default: you need to define a user with the role “manager-gui” in/etc/tomcat7/tomcat-users.xml before you can access it.

The second one is the host-manager webapp, which you can access by default at http://yourserver:8080/host-manager/html. It can be used to create virtual hosts dynamically.

Access to the host-manager application is also protected by default: you need to define a user with the role “admin-gui” in /etc/tomcat7/tomcat-users.xml before you can access it.

b) Configuration settings of Tomacat server:


Tomcat configuration files can be found in /etc/tomcat7. Only a few common configuration tweaks will be described here, please see Tomcat 7.0 documentation for more.
Changing default ports

1. Port Configuration : By default Tomcat runs a HTTP connector on port 8080 and an AJP connector on port 8009. You might want to change those default ports to avoid conflict with another application on the system. This is done by changing the following lines in /etc/tomcat7/server.xml:

<Connector port=”8080″ protocol=”HTTP/1.1″
               redirectPort=”8443″ />

<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />

2. JAVA Configuration : By default Tomcat will run preferably with OpenJDK JVMs, But we can chnge this default JVM and can set it with SUN JAVA or Oracle JAVA. WE can force Tomcat to use a specific JVM by setting JAVA_HOME in /etc/default/tomcat7:


3. Configuring users role : Usernames, passwords and roles (groups) can be defined centrally in a Servlet container. This is done in the /etc/tomcat7/tomcat-users.xml file:

<role rolename=”admin”/> <user username=”tomcat” password=”passwd” roles=”admin”/>

After installing the tomcat7 using “apt-get” tomcat create following directory on ubuntu:

1./etc/tomcat7/  /contains configuration files., tomcat-users.xml ,server.xml catalina.policy */

2./usr/share/tomcat7 /* Main Tomcat folder containing scripts and links to other directories* /



5./usr/share/tomcat7-examples /* contains some built in exaple for testing            purpose */

5./var/cache/tomcat7  /* contains catalina and catalina.policy. */

6./var/lib/tomcat7/webapps /* where we deploy our web app. */

7./var/log/tomcat7  /* contains log file related to tomcat server */

8./usr/share/tomcat7/bin contains many binary like, ,

The tomcat comes with alredy deployed 5 app:

    The default home page: http://localhost:8080/
    Tomcat 7’s local documentation: http://localhost:8080/docs/
    Examples of Servlets and JSP: http://localhost:8080/examples/
    The host-manager to handle virtual hosts: http://localhost:8080/host-manager/
    The manager to administer web applications: http://localhost:8080/manager/html

Deploy and handle web applications :

 The GUI way:
 The easiest way is to use the manager webapp http://localhost:8080/manager/html. Use the username/password you defined as manager in tomcat-users.xml. Once logged in you can see five already deployed web applications. Add yours through the “Deploy” area and then stop/start/undeploy it with the “Applications” area.

Tags: Installing the Tomcat 7 on linux/ubuntu 12.04,install tomcat 7 on linux ubuntu,how to install tomcat 7 on linux ubuntu,install tomcat 8 ubuntu 14.04 apt-get,install tomcat 8 ubuntu apt-get,how to start tomcat in ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *