7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Cent OS 8にTomcat 9をインストール

Last updated at Posted at 2020-04-23

#はじめに
CentOS-8.1.1911-x86_64を「最低限のインストール」でインストールした環境にTomcat 9をインストールします。
JAVAを事前にインストールしておく必要があります。
JAVAのインストールはこちらを参考にして下さい。

#ユーザー作成

useradd -s /sbin/nologin tomcat

#ダウンロード

curl -O http://ftp.yz.yamagata-u.ac.jp/pub/network/apache/tomcat/tomcat-9/v9.0.34/bin/apache-tomcat-9.0.34.tar.gz

#展開・ファイル移動

tar xvzf apache-tomcat-9.0.34.tar.gz -C /opt
ln -s /opt/apache-tomcat-9.0.34 /opt/apache-tomcat
chown -R tomcat. /opt/apache-tomcat-9.0.34

#パスを通す

echo "export CATALINA_HOME=/opt/apache-tomcat" > /etc/profile.d/tomcat.sh
source /etc/profile

#サービス定義ファイルを作成

vi /etc/systemd/system/tomcat.service
tomcat.service
[Unit]
Description=Apache Tomcat 9
After=syslog.target network.target

[Service]
User=tomcat
Group=tomcat
Type=oneshot
PIDFile=/opt/apache-tomcat/tomcat.pid
RemainAfterExit=yes

ExecStart=/opt/apache-tomcat/bin/startup.sh
ExecStop=/opt/apache-tomcat/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

#権限付与

chmod 755 /etc/systemd/system/tomcat.service

#ファイヤーウォールの設定

firewall-cmd --add-port=8080/tcp --zone=public --permanent
systemctl restart firewalld

#起動

systemctl start tomcat

#再起動

systemctl restart tomcat

#停止

systemctl stop tomcat

#自動起動設定

systemctl enable tomcat

#バージョン確認

/opt/apache-tomcat/bin/version.sh
Using CATALINA_BASE:   /opt/apache-tomcat
Using CATALINA_HOME:   /opt/apache-tomcat
Using CATALINA_TMPDIR: /opt/apache-tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/apache-tomcat/bin/bootstrap.jar:/opt/apache-tomcat/bin/tomcat-juli.jar
NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Server version: Apache Tomcat/9.0.34
Server built:   Apr 3 2020 12:02:52 UTC
Server number:  9.0.34.0
OS Name:        Linux
OS Version:     4.18.0-147.8.1.el8_1.x86_64
Architecture:   amd64
JVM Version:    11.0.7+10
JVM Vendor:     AdoptOpenJDK

#動作確認
http://hostname:8080/docs/
にアクセスして以下のページが表示されればOKです。

tomcat-docs.jpg

#まとめ
以上でインストール出来ました。

7
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?