Tomcat
- 印刷する
- PDF
Tomcat
- 印刷する
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Classic/VPC環境で利用できます。
Tomcatは、Linuxを OSとして使用しながら本サービスを活用したウェブアプリケーションサーバおよびサーブレットコンテナプラットフォームです。安定性に優れた NAVERクラウドプラットフォームの Computeインフラサービスに自動的に構成され、いくつかの段階の設定を行うことですぐにサービスを開始できます。
Tomcatを使用するメリットは、次の通りです。
- NAVERクラウドプラットフォームのインフラサービスを活用して、安定的に Tomcatを利用できます。
- サーバイメージとスペックを選択して Tomcatサーバを自動的にインストールして利用できます。
参考
NAVERクラウドプラットフォームの Tomcatで使用されるソフトウェアの詳細については、次のウェブサイトでご確認ください。
サーバ作成とアクセス
サーバの作成とアクセス方法は、NAVERクラウドプラットフォームの一般的なサーバ作成方法と同じです。詳しい手順と参考になるガイドは、次の通りです。
手順 | 説明 |
---|---|
1. ACG設定 |
|
2. サーバ作成 |
|
3. グローバル IPアドレスの設定 |
|
4. ポートフォワードの設定(Classic専用) |
|
5. 管理者パスワードの確認 |
|
6. サーバアクセス |
|
参考
- サーバにアクセスしてログインした後は、rootアカウントのパスワードを覚えやすい別のパスワードに変更することをお勧めします。
passwd root
コマンドを入力して新しいパスワードを設定してください。 - グローバル IPアドレスと ACGに問題がなくても Tomcat Webサービスに接続できない場合、ウェブサーバのプロセスが停止している可能性があります。ターミナルプログラムで再起動コマンド(
systemctl start httpd
)を実行し、プロセスを再起動してください。
サーバを使用する
サーバが作成されると自動的に Tomcatウェブアプリケーションサーバがインストールされ、簡単に使用できます。
サーバに接続した状態で次のコマンドを使用できます。
- サービス停止:
systemctl stop tomcat
- サービス実行:
systemctl start tomcat
- サービス状態の確認
[root@tomcat-c73 ~]# systemctl status tomcat ● tomcat.service - Apache Tomcat Web Application Container Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2022-10-05 13:11:14 KST; 10s ago Process: 6448 ExecStop=/opt/tomcat/bin/shutdown.sh (code=exited, status=0/SUCCESS) Process: 6530 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS) Main PID: 6537 (java) CGroup: /system.slice/tomcat.service └─6537 /usr/lib/jvm/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.manager=org.ap... Oct 05 13:11:14 tomcat-c73 systemd[1]: Starting Apache Tomcat Web Application Container... Oct 05 13:11:14 tomcat-c73 startup.sh[6530]: Tomcat started. Oct 05 13:11:14 tomcat-c73 systemd[1]: Started Apache Tomcat Web Application Container.
- サービスポート状態を確認
[root@tomcat-c73 ~]# netstat -na | grep 18080 tcp 0 0 0.0.0.0:18080 0.0.0.0:* LISTEN
- バージョン情報を確認
[root@tomcat-c73 ~]# /opt/tomcat/bin/version.sh Using CATALINA_BASE: /opt/tomcat Using CATALINA_HOME: /opt/tomcat Using CATALINA_TMPDIR: /opt/tomcat/temp Using JRE_HOME: /usr Using CLASSPATH: /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar Using CATALINA_OPTS: Server version: Apache Tomcat/8.5.78 Server built: Mar 31 2022 16:05:28 UTC Server number: 8.5.78.0 OS Name: Linux OS Version: 3.10.0-514.2.2.el7.x86_64 Architecture: amd64 JVM Version: 1.8.0_345-b01 JVM Vendor: Red Hat, Inc.
ウェブブラウザの確認
サーバが割り当てられたグローバル IPアドレスにポートが正常に動作しているか確認できます。
ウェブブラウザを実行し、URLを入力します。
http(s)://(グローバル IPアドレス):(Tomcatサービスポート)
正常に動作する場合、Tomcatのデフォルトページが表示されます。
Managerモジュールウェブ実行のユースケース
アカウント情報を設定して Tomcat Managerや Tomcat Host Managerモジュールをウェブで実行できます。
注意
Tomcatサーバのセキュリティのため、Tomcat Managerや Tomcat Host Managerは無効にしておくことをお勧めします。必要な場合のみアクセス可能な IPアドレス帯域を設定し、特定の運用者と帯域でアクセスできるようにしてください。
- サーバに接続した状態で
vi /opt/tomcat/conf/tomcat-users.xml
コマンドを入力します。- Tomcat Managerアクセスアカウントを設定できるエディタが開きます。
- [I] キーを押して入力モードをオンにした後、user入力領域にアクセスアカウント情報を追加します。
- このユースケースでは、usernameは admin、パスワードは passwordで入力されており、Managerと Host Managerの両方にアクセス権を付与しています。
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
...(中略)
The users below are wrapped in a comment and are therefore ignored. If you
wish to configure one or more of these users for use with the manager web
application, do not forget to remove the <!.. ..> that surrounds them. You
will also need to set the passwords to something appropriate.
-->
<user username="admin" password="password" roles="manager-gui,admin-gui"/>
<!--
The sample user and role entries below are intended for use with the
examples web application. They are wrapped in a comment and thus are ignored
when reading this file. If you wish to configure these users for use with the
examples web application, do not forget to remove the <!.. ..> that surrounds
them. You will also need to set the passwords to something appropriate.
-->
...(中略)
</tomcat-users>
- 情報入力が完了したら、 [Esc] キーを押して入力モードをオフにし、
:wq
コマンドを入力してエディタを終了します。 vi /opt/tomcat/webapps/manager/META-INF/context.xml
コマンドを入力します。- Tomcat Managerのアクセス IPアドレス範囲を設定できるエディタが開きます。
- [I] キーを押して入力モードをオンにした後、リモートアクセス許可 IPアドレスの範囲を変更します。
- このユースケースでは、すべての IPアドレス帯域からアクセスできるように Valve情報をコメントアウトします。
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
...(中略)
<Context antiResourceLocking="false" privileged="true" >
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
sameSiteCookies="strict" />
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
- [Esc] キーを押して入力モードをオフにした後、
:wq
を入力してエディタを終了します。 vi /opt/tomcat/webapps/host-manager/META-INF/context.xml
コマンドを入力します。- Tomcat Host Managerのアクセス IPアドレス範囲を設定できるエディタが開きます。
- [I] キーを押して入力モードをオンにした後、リモートアクセス許可 IPアドレスの範囲を変更します。
- このユースケースでは、すべての IPアドレス帯域からアクセスできるように Valve情報をコメントアウトします。
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
...(中略)
<Context antiResourceLocking="false" privileged="true" >
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
sameSiteCookies="strict" />
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
- [Esc] キーを押して入力モードをオフにした後、
:wq
を入力してエディタを終了します。 systemctl restart tomcat
コマンドを入力して Tomcatを再起動します。- ウェブブラウザで URLを入力し、Tomcat Managerまたは Tomcat Host Managerページにアクセスします。
- Tomcat Managerページ:
http(s)://(グローバル IPアドレス):(Tomcatサービスポート)/manager/html
- Tomcat Host Managerページ:
http(s)://(グローバル IPアドレス):(Tomcatサービスポート)/host-manager/html
- Tomcat Managerページ:
- ログインのポップアップが表示されたら、ステップ2で作成した usernameとパスワードを入力し、 [ログイン] ボタンをクリックします。
- 正常にログインすると、Tomcatウェブアプリケーションマネージャページまたは Tomcat仮想ホストマネージャページが表示されます。これで目的のコマンドを実行できます。
この記事は役に立ちましたか?