Before we dive in with the steps for Tomcat7 installation, let’s first talk a little about what Apache Tomcat is.
Apache Tomcat is nothing but a Web Server and also OPEN SOURCE (probably the most commonly one used today). It’s been developed by Apache Software Foundation (ASF).
It’s a web server and also has a servlet container. Tomcat is used to run Java applications - Java servlets, JSP , WebSocket etc.
It works on HTTP port 8080.
In this tutorial, we will learn how to install Tomcat7 on CentOS and then also install admin and manager packages and see how to use the manager-gui to upload, deploy, remove etc a JAVA .war file.
Step 1 - Check for Java Version
Tomcat 7 needs Java SE 6 or later.
Check for the existing java version in your machine using the following command -
~ Java -version

Tutorial - How To Install Java on CentOS/RHEL
Step 2 - Install Tomcat
Use the following command -
~ sudo yum install tomcat7
Answer yes at the confirmation question to be able to install all the related dependencies for Tomcat 7.
All the important Tomcat files will reside at /usr/share/tomcat7/
If you have a Tomcat application file ready to run then you can simply place the file in the /usr/share/tomcat7/webapps/ folder.
Step 3 -
Till now you have just installed the Tomcat server but the Tomcat service is not running yet.
So you need to start the Tomcat Server to be able to use it.
~ sudo service tomcat7 start
To check the status of the Tomcat server -
~ sudo service tomcat7 status
Step 4 -
To be able to access your Tomcat Server on a web browser -
Take your machine’s IP address and use port 8080 -
http://<IP Address>:8080 You should be able to see something like this -
Step 5 - Install ROOT page and Admin packages
There are some admin packages that are available to help you with the deployment of your Java applications and much more.
To install the packages, use the following command -
~ sudo yum install tomcat7-webapps tomcat7-admin-webapps
Answer yes for the confirmation question.
The above command will install the ROOT page, some example samples, manager to the /usr/share/tomcat7/webapps folder.
Step 6 - Create Users
To be able to use the manager package we need to login into the Tomcat Server. For this we will be creating users.
We need to edit the tomcat-users.xml file.
~ vi /usr/share/tomcat7/conf/tomcat-users.xml
This file already has the instructions on how to add the configuration details, read them carefully.
Everything is written inside the <tomcat-users> ….. </tomcat-users> tag.
We need to create users for the manager-gui and admin-gui to be able to access the manager we installed in the above step.
<!-- manager user can access only manager section, as specified in the roles -->
<role rolename="manager-gui" />
<user username="manager" password="_SECRET_PASSWORD_" roles="manager-gui" />
<!-- admin user can access manager and admin sections, as specified in the roles -->
<role rolename="admin-gui" />
<user username="admin" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" />
Step 7 - Restart the Tomcat Server
Once done editing the tomcat-users.xml file, you will have to restart the server.
~ sudo service tomcat7 restart
Step 8 - Open the manager gui
After restarting the server, the last step is to go to your web browser and open up the server as shown in the Step 4.
Click on Manager button on the right. You will be prompted to login with the credentials you made in Step 6.
You should see something like this -
This manager can be used to manage your Java applications. You can use this simple GUI to start, stop, reload, deploy and undeploy your applications. You can also run some diagnostics on your application.
And at the bottom, you can also see information of your server.
That’s it! You are now set to deploy your applications on Tomcat Server! :)


















