How to install Apache tomcat 9.0.6 on centos 7

To install Apache Tomcat 9.0.6 on CentOS 7

Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation. It executes Java servlets and renders Web pages that include Java Server Page coding and it is one of the most popular web servers used by the Java developers. In this tutorial, you will learn about the method to install Apache Tomcat 9.0.6 on CentOS 7.

Installation

Tomcat 9 is designed to run on Java SE 8 and later. So make sure you have installed correct version on your system.

[root@linuxhelp ~]# java -version
openjdk version " 1.8.0_131" 
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)

Download tomcat archive. You can download the latest from official website from the command line using the following command

[root@linuxhelp ~]# cd /usr/local/
root@linuxhelp local]# wget http://redrockdigimark.com/apachemirror/tomcat/tomcat-9/v9.0.6/bin/apache-tomcat-9.0.6.tar.gz
--2018-04-04 23:03:52--  http://redrockdigimark.com/apachemirror/tomcat/tomcat-9/v9.0.6/bin/apache-tomcat-9.0.6.tar.gz
Resolving redrockdigimark.com (redrockdigimark.com)... 119.18.61.94
Connecting to redrockdigimark.com (redrockdigimark.com)|119.18.61.94|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9494739 (9.1M) [application/x-gzip]
Saving to: ‘ apache-tomcat-9.0.6.tar.gz’ 

100%[========================================================================================> ] 9,494,739   47.9MB/s   in 0.2s   

2018-04-04 23:04:06 (47.9 MB/s) - ‘ apache-tomcat-9.0.6.tar.gz’  saved [9494739/9494739]

Extract the archive and then rename it.

[root@linuxhelp local]# tar xzf apache-tomcat-9.0.6.tar.gz 
[root@linuxhelp local]# mv apache-tomcat-9.0.6 tomcat9

Next, we have to Configure the environment variables. configure CATALINA_HOME environment variable in your system using following commands. Its required to run Tomcat server.

[root@linuxhelp local]# echo " export CATALINA_HOME=" /usr/local/tomcat9" "  > >  ~/.bashrc
[root@linuxhelp local]# source ~/.bashrc

Setup user accounts. In order to access the manager/admin pages you can to add users to users.xml file

[root@linuxhelp local]# vim /usr/local/tomcat9/conf/tomcat-users.xml
< tomcat-users xmlns=" http://tomcat.apache.org/xml" 
              xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" 
              xsi:schemaLocation=" http://tomcat.apache.org/xml tomcat-users.xsd" 
              version=" 1.0" > 
< !-- user manager can access only manager section --> 
< role rolename=" manager-gui"  /> 
< user username=" manager"  password=" PASSWORD"  roles=" manager-gui"  /> 

< !-- user admin can access manager and admin section both --> 
< role rolename=" admin-gui"  /> 
< user username=" admin"  password=" PASSWORD"  roles=" manager-gui,admin-gui"  /> 
< /tomcat-users> 

After adding users you have to start the tomcat service. simply extract the archive and start the tomcat server. Tomcat by default start on port 8080, So make sure no other application using the same port.

[root@linuxhelp local]# cd /usr/local/tomcat9/
[root@linuxhelp tomcat9]# ./bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat9
Using CATALINA_HOME:   /usr/local/tomcat9
Using CATALINA_TMPDIR: /usr/local/tomcat9/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat9/bin/bootstrap.jar:/usr/local/tomcat9/bin/tomcat-juli.jar
Tomcat started.

Access the tomcat in the browser by connecting your server on port 8080. Go to browser and navigate http://localhost:8080.

If you see the following page apache tomcat has been installed on your machine successfully. You can access the manager page using the manager app option



You can access the host manager page using the host manager option


With this, the method to install Apache Tomcat 9.0.6 on centos 7 comes to an end.

FAQ
Q
How do I make Tomcat start up faster?
A
Use the following link to make Tomcat start up faster as "make Tomcat start up faster"
Q
Whether Is Tomcat faster than serving static HTML pages than Apache httpd?
A
The serving page is entirely depending on how you configured in the server. For the configuration of Apache Tomcat, refer the link as below "https://marc.info/?l=tomcat-user&m=106036177509367&w=2"
Q
How to install Apache tomcat server on FreeBSD?
A
For the installation of Apache Tomcat on FreeBSD, use the link as below "https://www.linuxhelp.com/how-to-install-tomcat-in-freebsd/"
Q
How to download the latest version of Apache Tomcat?
A
For downloading the latest version of Apache Tomcat package from using the following link as below "https://tomcat.apache.org/download-80.cgi"
Q
How to install Apache Tomcat on LinuxMint?
A
For the installation of Apache Tomcat on Linuxmint, use the link as below "https://www.linuxhelp.com/how-to-install-tomcat9-on-linuxmint-18-3/"