This tutorial will help you to install and configure the Tomcat 9 server on CentOS 8 and RHEL 8 Linux systems.

Prerequisites

Shell access sudo priviledged account access

Step 1 – Install Java

Java is the primary requirement for running Tomcat 9 on CentOS 8 Linux system. Make sure you have Java 8 or higher version installed in your system. Use the following command to install OpenJDK on your system. Then check the installed Java version

Step 2 – Create Tomcat User

Many system administrators run Tomcat as a root user which is not the correct way for security purposes. So, create a separate account to run your Tomcat server on your system. The above command will create a user with the name “tomcat” with a group named “tomcat”.

Step 3 – Download Tomcat 9 Archive

The Apache Tomcat is available on official download pages, Where you can select the nearest peers to download Tomcat faster. To download Apache Tomcat archive file from Apache tomcat official download server use the following command: Then extract the archive file and copy all the files under the tomcat home directory Also, set the proper ownership of all files.

Step 4 – Enable Host/Manager for Remote IP

By default Tomcat manager and host-manager, pages are enabled to access from localhost only. To access these pages from the remote system, you have to allow your IP or IP range in the application-specific context.xml file.

Manager – /opt/tomcat/webapps/manager/META-INF/context.xml Host Manager – /opt/tomcat/webapps/host-manager/META-INF/context.xml

Edit both of the above files one by one and add your IP address (like 192.168.1.10) or range of IP addresses to allow access. For reference see the below screenshot.

You can also totally comment on these Valve entries to allow all.

Step 5 – Setup User Accounts

Now, configure your tomcat with user accounts to secure access to admin/manager pages. To do this, edit /opt/tomcat/conf/tomcat-users.xml file in your editor and paste the following code inside tags. We recommend changing the password in the below configuration with high secured password. Save the file and close.

Step 6 – Create Tomcat Start Script

Tomcat provides bash scripts to start, and stop service. But, to make it simple, create a startup script to manage Tomcat as systemd service. Let’s create a tomcat.service file with the following content: Add the below snippet. Reload the systemd daemon service to apply changes Then, enable and start the Tomcat service on your system Tomcat server works on port 8080 default. To access Tomcat on the web browser by connecting your server to port 8080. If you are connecting from the local machine then use the localhost. To connect from a remote machine use the IP address of the system with port:

Conclusion

You have a running Tomcat 9 server on CentOS 8 system. You may need to create a Virtual host or configure a SSL certificate in Tomcat.

How to Install Tomcat 9 on CentOS RHEL 8   TecAdmin - 90How to Install Tomcat 9 on CentOS RHEL 8   TecAdmin - 16