Prerequisites

A running Ubuntu 20.04 system with shell access of root or sudo privileged account access.

Installing Java

You must have Java installed on your system to run the tomcat server. Tomcat 9 is required to have Java 8 or a higher version installed on your system. Use the following command to install OpenJDK on your system or skip if already installed. Check the current active Java version:

Create A Tomcat Account

We recommend creating a separate user account to run the tomcat web server on the Ubuntu system. This will be good for security purposes. To create account execute following command: The above command will create a user and group with the name “tomcat” on your system.

Download Tomcat Archive

The Apache Tomcat development team releases the latest version of Tomcat from time to time. So it will be good check download latest Tomcat version from the official download server. Use the below command to download Tomcat 9.0.58. Once the file is downloaded, extracted the archive file and copy all content to the tomcat home directory. Also, set the proper ownership of all files. You can also download Tomcat 8 instead of Tomcat 9 and change above commands accordingly. Remaining steps will be same for both.

Enable Host/Manager Remote Access

By default Tomcat manager and host-manager, pages are accessible from the localhost system only. To allow access to these pages from the remote system, you need to create the following configuration files. First create manager xml file: Add the following content Then create host-manager xml file: Add the following content Save both files and close.

Create Tomcat Access Credentials

Now, configure your tomcat with user accounts to secure access of admin/manager pages. To do this, edit 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. Add the following values. Make sure to change the password for admin and manager access. Save file and close.

Create A Tomcat Startup Script

Tomcat provides bash scripts to start, stop service. But, to make it simpl, create a startup script to manage Tomcat as systemd service. Let’s create a tomcat.service file with the following content: Reload the systemd daemon service to apply changes Then, enable and start Tomcat service on your system

Accessing Tomcat

Tomcat server works on port 8080 default. To access Tomcat on the web browser by connecting your server on port 8080. If you are connecting from the local machine then use http://localhost or use the IP address for the remote system with port:

Conclusion

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

How to Install Tomcat 9 on Ubuntu 20 04   TecAdmin - 68How to Install Tomcat 9 on Ubuntu 20 04   TecAdmin - 56How to Install Tomcat 9 on Ubuntu 20 04   TecAdmin - 74