Objective

The objective is to install Tomcat 8 server on Ubuntu 18.04 Bionic Beaver Linux

Operating System and Software Versions

  • Operating System: - Ubuntu 18.04 Bionic Beaver
  • Software: - Tomcat 8.5.21

Requirements

Privileged access to your Ubuntu System as root or via sudo command is required.

Difficulty

EASY

Conventions

  • # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - requires given linux commands to be executed as a regular non-privileged user

Instructions

Install Tomcat 8 Server

The easiest way to install Tomcat 8 on Ubuntu 18.04 is to use tasksel command. If you are running Ubuntu Server 18.04 the tasksel command is already pre-installed.

However, if you are running Ubuntu Desktop 18.04 you will need to install it before you can install Tomcat server. Open up terminal and execute:
$ sudo apt install tasksel
Once ready, use tasksel command to install Tomcat 8 on your Ubuntu 18.04 host:
$ sudo tasksel install tomcat-server
If successful check for an open port 8080 using ss command to see whether Tomcat is up and running as expected:
$ ss -tln
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port
LISTEN      0      128       0.0.0.0:5355                  0.0.0.0:*
LISTEN      0      128       0.0.0.0:22                    0.0.0.0:*
LISTEN      0      128          [::]:5355                     [::]:*
LISTEN      0      100             *:8080                        *:*
LISTEN      0      128          [::]:22                       [::]:*
LISTEN      0      1      [::ffff:127.0.0.1]:8005                        *:*
The Tomcat 8 server on Ubuntu 18.04 will by default start after reboot. To disable and enable Tomcat 8 server to start after reboot execute:
$ sudo systemctl enable tomcat8
OR
$ sudo systemctl disable tomcat8

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Open firewall ports for Tomcat server

In case you have already the ufw firewall the following linux command will allow TCP incoming traffic from any source to your Tomcat 8 server's port 8080:
$ sudo ufw allow from any to any port 8080 proto tcp
If you wish to make your firewall rules more strict visit our How to Open/Allow incoming firewall port guide for more information.

Test Tomcat 8 server

It is time to perform a simple test. Given that your Tomcat 8 server can be resolved via tomcat-ubuntu you can now visit Tomcat's 8 main page.

Start your web browser and enter URL http://tomcat-ubuntu:8080:
Tomcat 8 server on Ubuntu 18.04
Tomcat 8 server on Ubuntu 18.04. This page is a great starting point for your Tomcat 8 server configuration. Read it carefully.
Next, we are going to create a new example user to access the manager webapp and the host-manager webapp. To do so edit the Tomcat's user list file /etc/tomcat8/tomcat-users.xml:
$ sudo nano /etc/tomcat8/tomcat-users.xml
and add the following information above the </tomcat-users> tag to create a new user tomcat with password pass:
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="pass" roles="admin-gui,manager-gui"/>
Save the file and restart Tomcat server:
$ sudo service tomcat8 restart
Use the new user credentials to access Tomcat Web Application Manager:
Tomcat Web Application Manager on Ubuntu 18.04
Navigate to http://tomcat-ubuntu:8080/manager/html to access Tomcat Web Application Manager
Tomcat Web Application Manager Interface
Tomcat Web Application Manager Interface


Tomcat Virtual Host Manager on Ubuntu 18.04
To visit Tomcat Virtual Host Manager enter URL: http://tomcat-ubuntu:8080/host-manager/html followed by tomcat user's credentials.
Tomcat 8 documentation on Ubuntu 18.04
Tomcat 8 documentation page
Tomcat 8 Examples on Ubuntu 18.04
Tomcat 8 Examples on Ubuntu 18.04
Tomcat 8 <b><noscript><img src=Hello World example on Ubuntu 18.04">
Tomcat 8 Hello World example on Ubuntu 18.04 Bionic Beaver
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.