[LINUX] Install Apache Tomcat 9 on Ubuntu 19.10 Eoan Ermine Hello World

Install Apache Tomcat 9

Install the tomcat9 package.

$ sudo apt install tomcat9

The tomcat9-common and libtomcat9-java packages are also installed as dependencies.

$ dpkg -l | grep tomcat
ii  libtomcat9-java                      9.0.24-1                               all          Apache Tomcat 9 - Servlet and JSP engine -- core libraries
ii  tomcat9                              9.0.24-1                               all          Apache Tomcat 9 - Servlet and JSP engine
ii  tomcat9-common                       9.0.24-1                               all          Apache Tomcat 9 - Servlet and JSP engine -- common files

You can check if Apache Tomcat 9 is running with curl etc.

$ curl http://localhost:8080/
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Apache Tomcat</title>
</head>

<body>
<h1>It works !</h1>
(The following is omitted)

The top page is in the / var / lib / tomcat9 / webapps / ROOT directory.

$ tree /var/lib/tomcat9/webapps/
/var/lib/tomcat9/webapps/
└── ROOT
    ├── META-INF
    │   └── context.xml
    └── index.html
$ ls -lR /var/lib/tomcat9/webapps/
/var/lib/tomcat9/webapps/:
4 in total
drwxr-xr-x 3 root root 4096 January 19 12:56 ROOT

/var/lib/tomcat9/webapps/ROOT:
8 in total
drwxr-xr-x 2 root root 4096 January 19 12:25 META-INF
-rw-r--r--1 root root 1899 January 19 12:56 index.html

/var/lib/tomcat9/webapps/ROOT/META-INF:
4 in total
-rw-r--r--1 root root 49 January 19 12:25 context.xml

Deploy a Hello World web application

Create a hello directory under webapps and set permissions for general user accounts.

$ sudo mkdir /var/lib/tomcat9/webapps/hello
$ sudo chown hoge:hoge /var/lib/tomcat9/webapps/hello

Place Hello World JSP files in /var/lib/tomcat9/webapps/hello/index.jsp.

<%@ page contentType="text/html; charset=utf-8" %><html><body>
Hello JSP World!<br>
java.version: <%= System.getProperty("java.version") %><br>
java.vm.name: <%= System.getProperty("java.vm.name") %><br>
</body></html>

Check the operation with curl etc.

$ curl http://localhost:8080/hello/
<html><body>
Hello JSP World!<br>
java.version: 11.0.5<br>
java.vm.name: OpenJDK 64-Bit Server VM<br>
</body></html>

Start and stop Apache Tomcat 9

If you check tomcat registered in systemd, the unit name is tomcat9.

$ systemctl list-unit-files --type=service | grep tomcat
tomcat9.service                        enabled    

You can start Tomcat 9 with systemctl start tomcat9.

$ sudo systemctl start tomcat9

You can stop Tomcat 9 with systemctl stop tomcat9.

$ sudo systemctl stop tomcat9

You can restart Tomcat 9 with systemctl restart tomcat9.

$ sudo systemctl restart tomcat9

tomcat9 package file list

You can check it with the dpkg -L command. You can also find the location of the configuration file etc.

$ dpkg -L tomcat9
/.
/etc
/etc/cron.daily
/etc/cron.daily/tomcat9
/etc/logrotate.d
/etc/rsyslog.d
/etc/rsyslog.d/tomcat9.conf
/etc/tomcat9
/etc/tomcat9/Catalina
/etc/tomcat9/policy.d
/etc/tomcat9/policy.d/01system.policy
/etc/tomcat9/policy.d/02debian.policy
/etc/tomcat9/policy.d/03catalina.policy
/etc/tomcat9/policy.d/04webapps.policy
/etc/tomcat9/policy.d/50local.policy
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/tomcat9.service
/usr
/usr/lib
/usr/lib/sysusers.d
/usr/lib/sysusers.d/tomcat9.conf
/usr/lib/tmpfiles.d
/usr/lib/tmpfiles.d/tomcat9.conf
/usr/libexec
/usr/libexec/tomcat9
/usr/libexec/tomcat9/tomcat-start.sh
/usr/libexec/tomcat9/tomcat-update-policy.sh
/usr/share
/usr/share/doc
/usr/share/doc/tomcat9
/usr/share/doc/tomcat9/copyright
/usr/share/tomcat9
/usr/share/tomcat9/default.template
/usr/share/tomcat9/etc
/usr/share/tomcat9/etc/catalina.properties
/usr/share/tomcat9/etc/context.xml
/usr/share/tomcat9/etc/jaspic-providers.xml
/usr/share/tomcat9/etc/logging.properties
/usr/share/tomcat9/etc/server.xml
/usr/share/tomcat9/etc/tomcat-users.xml
/usr/share/tomcat9/etc/web.xml
/usr/share/tomcat9/logrotate.template
/usr/share/tomcat9-root
/usr/share/tomcat9-root/default_root
/usr/share/tomcat9-root/default_root/META-INF
/usr/share/tomcat9-root/default_root/META-INF/context.xml
/usr/share/tomcat9-root/default_root/index.html
/var
/var/cache
/var/cache/tomcat9
/var/lib
/var/lib/tomcat9
/var/lib/tomcat9/lib
/var/lib/tomcat9/webapps
/var/log
/var/log/tomcat9
/usr/share/doc/tomcat9/README.Debian
/usr/share/doc/tomcat9/changelog.Debian.gz
/var/lib/tomcat9/conf
/var/lib/tomcat9/logs
/var/lib/tomcat9/work

Reference material

--Ubuntu – Details about eoan's tomcat9 package

Recommended Posts

Install Apache Tomcat 9 on Ubuntu 19.10 Eoan Ermine Hello World
Install Apache 2.4 on Ubuntu 19.10 Eoan Ermine and run CGI
Reverse proxy with Apache 2.4 on Ubuntu 19.10 Eoan Ermine
How to update security on Ubuntu 19.10 Eoan Ermine
Install TensorFlow on Ubuntu
Install PySide2 on Ubuntu
Install JModelica on Ubuntu
Hello World on Django
Install Python 3.3 on Ubuntu 12.04
Install Theano on Ubuntu 12.04
Install angr on Ubuntu 18.04
Install pip / pip3 on Ubuntu
Install tomcat 9 on Cent OS 8
Install GoLand IDE on Ubuntu
Install OpenCV on Ubuntu + python
wsl Install PostgreSQL on Ubuntu 18.04
Install tomcat 5.5 on Amazon Linux.
[ROS] Install ROS (melodic) on Ubuntu (18.04)
Install Caffe on Ubuntu 14.04 (GPU)
Install Docker on WSL Ubuntu 18.04
Hello World (beginners) on Django
Install CUDA10.1 + cuDNN7.6.5 + tensorflow-2.3.0 on Ubuntu 18.04
Install Python 3.8 on Ubuntu 18.04 (OS standard)
Install Caffe on Ubuntu 14.04 (CPU mode)
Install Mecab and mecab-python3 on Ubuntu 14.04
Install and run dropbox on Ubuntu 20.04
Install OpenCV and Chainer on Ubuntu
Install CUDA 8.0 and Chainer on Ubuntu 16.04
Install Python 3.8 on Ubuntu 20.04 (OS standard)
Install fabric on Ubuntu and try
Install Python 3.9 on Ubuntu 20.04 (OS standard?)
Install confluent-kafka for Python on Ubuntu
Install Python 2.7 on Ubuntu 20.04 (OS standard?)
How to install Go on Ubuntu
ROS study # 1 Install ros-noetic on ubuntu 20.04
Until you install Apache and Tomcat on Linux (CentOS) and deploy Java apps
Packet filtering settings using iptables on Ubuntu 19.10 Eoan Ermine and their persistence
How to build Hello, World on #Nix
Steps to install Python environment on Ubuntu
Install Pleasant on Ubuntu 20.04 (.NetCore3.1 / PostgreSQL version)
Install ubuntu on 32bit UEFI Ultra Notebook
Install Caffe running 3D-CNN on clean Ubuntu 14.04
How to install Apache (httpd) on CentOS7
Install Puppet Master and Client on Ubuntu 16.04
How to install php7.4 on Linux (Ubuntu)
How to install Apache (httpd) on CentOS8
Install pyenv and Python 3.6.8 on Ubuntu 18.04 LTS
Hello world
I can't install Dask with pip on Ubuntu
Install python package in personal environment on Ubuntu
[Procedure memo] Install Python3 + OpenSSL locally on Ubuntu
[Note] Install wxPython 3.x on Linux Mint (Ubuntu)
Hello World with nginx + uwsgi + python on EC2
Flask Hello World cannot be displayed on VPS
Install the latest Cuda + CuDNN on Ubuntu 18.04 @ Spring 2020
Install MongoDB on Ubuntu 16.04 and operate via python
Install Ubuntu 20.04 LTS (Server) 64bit version on RaspberryPi3B +