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
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>
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
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
--Ubuntu – Details about eoan's tomcat9 package
Recommended Posts