Apache Tomcat (earlier known as Jakarta Tomcat) is an open-source web server developed by Apache Foundation to provide a pure Java HTTP server, which will enable you to run Java files easily, which means that Tomcat is not a normal server like Apache or Nginx because its main goal is to provide a good web environment to run Java applications only unlike other normal web servers

In this blog, I will show you how to install and configure apache tomcat on centos7

Steps to perform

  • Install Java.
  • Install Apache Tomcat.
  • Configure Apache Tomcat.
  • Changing Port No.

Step 1:- Install Java

For Installing the Tomcat make sure that java is installed and the path is setup

sudo yum install java-1.8*

After installing java check the java version

for path setup please follow this link here

Step 2:- Install Apache Tomcat.

Now Install the latest version of apache tomcat from the apache download page
https://tomcat.apache.org/download-90.cgi

Wget the latest version of the apache tomcat

cd /opt
wget https://downloads.apache.org/tomcat/tomcat-8/v8.5.57/bin/apache-tomcat-8.5.57.tar.gz
sudo tar -xzf apache-tomcat-8.5.57.tar.gz
sudo mv apache-tomcat-8.5.57 tomcat

Now start the tomcat

cd /opt/tomcat/bin
./startup.sh

It will look like this

Step 3:- Change port no.(optional)

If you want to change the port number of the apache tomcat from 8080 to other then we have to edit server.xml that is present in /opt/tomcat/conf
Before making changes in the server.xml make sure tomcat is shutdown

cd /opt/tomcat
./shutdown.sh

open the server.xml file and make some changes

sudo vi /opt/tomcat/conf/server.xml

Find the Connector port and change it to your desire port
save and exit

Now start the tomcat and access the server HTTP://ipaddress:8089

cd /opt/tomcat/bin
./startup.sh

Access via browser

Step 4:- Configure Apache Tomcat

By default, you only able to access the default Tomcat page, to access admin and other, like Server Status, Manager App, and Host Manager. You need to configure user accounts for admins and managers.

To get access you need to edit the tomcat-users.xml file located in /opt/tomcat/conf

sudo vi /opt/tomcat/conf/tomcat-users.xml

Add the below line in the tomcat-user.xml

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

Save and exit
Restart the Tomcat server

Access the Admin Section by clicking on server status on the Tomcat console.
It will prompt and ask for user name and passwd

username:-admin
password:-admin

After entering credentials you will find a new page like this

Congratulations… You follow all the steps and configure Apache tomcat server on centos 7

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