How to install Tomcat 11 in CentOS 7/8

First we need java. Tomcat11 requires Java Development Kit(JDK) 21 or later versions. You can download and install with following link https://www.oracle.com/java/technologies/downloads

After the installaton you can check version.

java -version

 

Please note that, if you have multiple java installed in your sever. You need to set JAVA_HOME environment parameter to set correct version.

Download the tomcat11 installation file

wget https://downloads.apache.org/tomcat/tomcat-11/v11.0.0-M14/bin/apache-tomcat-11.0.0-M14.tar.gz

After download create tomcat user in linux and copy tar file to tomcat user home directory and change ownership

groupadd tomcat
useradd -g tomcat tomcat

login with tomcat user.

Extract it.

 tar xvfz apache-tomcat-11.0.0-M14.tar.gz

 

By default, Tomcat listens on port 8080. If you want to change this, you can edit conf/server.xml file and change Connector element.

 

 

Now we can start tomcat to move bin directory

./starup.sh

 

Checking java process

ps -ef | grep java

 

 

and we can check log file moving logs directory and find “Server startup in” line.

tail -100f catalina.out

 

and we need to configure tomcat security.

By default, Tomcat does not require authentication to access its web interface. To secure Tomcat, you can add a username and a password to conf/tomcat-users.xml

<user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"

also we need to comment following lines in webapps/manager/META-INF/context.xml

 <!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="192\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->

Now we can restart tomcat moving to bin directory and type command

./shutdown.sh

./startup.sh

Finally we can login from browser with  http://<YOUR IP>:8080

Ok that’s it.

This entry was posted in Linux, Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

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