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.For this tutorial, I’m using Ubuntu 14.04 x64 with 512 MB of RAM from Digital Ocean. The cost is only $5 per month!
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
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
</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
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.
Tomcat Web Application Manager
Tomcat Virtual Host Manager
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
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