Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation that allows you to run Java Servlet and JavaServer Pages based web applications.

Install Apache Tomcat 7

We will first do a package repository update:

sudo apt-get update

Next, we will install Apache Tomcat 7:

sudo apt-get install tomcat7 tomcat7-docs tomcat7-admin tomcat7-examples

Apache Tomcat 7 is now installed. You can confirm Apach Tomcat is working by going to port 8080.

http://<ip address>:8080

Remember to replace <ip address> with your server’s IP address.

You should see a large heading title “It works !” followed by more generic information.

To run Java application, you will need to install the Java Development Kit (JDK). You can find my tutorial on how-to install Java on Ubuntu here.

Now we need to setup the user account to access the admin / manager pages.

sudo vi /etc/tomcat7/tomcat-users.xml

Next locate <tomcat-users> and </tomcat-users>, and add the following inbetween them:

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

Make sure you change admin and password and then save and exit.

Next restart Apache Tomcat:

sudo /etc/init.d/tomcat7 restart

You’re all done. We can now access the docs, examples and manager via HTTP.


http://<ip address>:8080/docs/


http://<ip address>:8080/examples

Tomcat Web Application Manager

http://<ip address>:8080/manager/html/

Tomcat Virtual Host Manager

http://<ip address>:8080/host-manager/html/

For the Tomcat Web Application Manager and Tomcat Virtual Host Manager, you’ll be prompted for a username and password. The username and password is what you set in the tomcat-users.xml file.

If you want to stop the access of the docs and examples via HTTP, go to the Tomcat Web Application Manager and look for the “Applications” section. Under the column “Path” locate /docs and then in the same row, look for and click on the stop button under the Commands column; do the same for examples.