IT練習ノート

IT関連で調べたこと(実際は嵌ったこと)を書いています。

EC2にTomcatインストール

いつもインストール方法を忘れてしまうので改めてメモ。

(1)yumの更新

[root@ip-xxx-xx-x-xxx ec2-user]# yum update
読み込んだプラグイン:priorities, update-motd, upgrade-helper
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ aws-cfn-bootstrap.noarch 0:1.3-17.amzn1 を 更新
---> パッケージ aws-cfn-bootstrap.noarch 0:1.4-0.amzn1 を アップデート
---> パッケージ curl.x86_64 0:7.36.0-2.44.amzn1 を 更新
---> パッケージ curl.x86_64 0:7.36.0-2.45.amzn1 を アップデート

(2)tomcatのインストール(最新じゃなかった。。。)

[root@ip-xxx-xx-x-xxx ec2-user]# yum install tomcat6
読み込んだプラグイン:priorities, update-motd, upgrade-helper
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ tomcat6.noarch 0:6.0.37-1.3.amzn1 を インストール
--> 依存性の処理をしています: tomcat6-lib = 6.0.37-1.3.amzn1 のパッケージ: tomcat6-6.0.37-1.3.amzn1.noarch

(3)アドミンのアプリをインストールする。

[root@ip-xxx-xx-x-xxx ec2-user]# yum install tomcat6-webapps tomcat6-admin-webapps
読み込んだプラグイン:priorities, update-motd, upgrade-helper
amzn-main/latest                                                                                                                                                                     | 2.1 kB     00:00     
amzn-updates/latest                                                                                                                                                                  | 2.3 kB     00:00     
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ tomcat6-admin-webapps.noarch 0:6.0.37-1.3.amzn1 を インストール
---> パッケージ tomcat6-webapps.noarch 0:6.0.37-1.3.amzn1 を インストール

(4)インストール先の確認

[root@ip-xxx-xx-x-xxx ec2-user]# ls -l /usr/share/tomcat6
合計 4
drwxr-xr-x 2 root root   4096  426 08:19 bin
lrwxrwxrwx 1 root tomcat   12  426 08:19 conf -> /etc/tomcat6
lrwxrwxrwx 1 root root     23  426 08:19 lib -> /usr/share/java/tomcat6
lrwxrwxrwx 1 root root     16  426 08:19 logs -> /var/log/tomcat6
lrwxrwxrwx 1 root root     23  426 08:19 temp -> /var/cache/tomcat6/temp
lrwxrwxrwx 1 root root     24  426 08:19 webapps -> /var/lib/tomcat6/webapps
lrwxrwxrwx 1 root root     23  426 08:19 work -> /var/cache/tomcat6/work

(5)ユーザの設定

[root@ip-xxx-xx-x-xxx ec2-user]# vim /etc/tomcat6/tomcat-users.xml 

(6)サービスの開始

[root@ip-xxx-xx-x-xxx ec2-user]# /sbin/service tomcat6 start
Starting tomcat6:                                          [  OK  ]
[root@ip-xxx-xx-x-xxx ec2-user]# 

(7)EC2側でポートの設定をする。

上記(5)のユーザの設定は、下記の29から35行目を参考にユーザの設定を行う。

  1 <?xml version='1.0' encoding='utf-8'?>
  2 <!--
  3   Licensed to the Apache Software Foundation (ASF) under one or more
  4   contributor license agreements.  See the NOTICE file distributed with
  5   this work for additional information regarding copyright ownership.
  6   The ASF licenses this file to You under the Apache License, Version 2.0
  7   (the "License"); you may not use this file except in compliance with
  8   the License.  You may obtain a copy of the License at
  9 
 10       http://www.apache.org/licenses/LICENSE-2.0
 11 
 12   Unless required by applicable law or agreed to in writing, software
 13   distributed under the License is distributed on an "AS IS" BASIS,
 14   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15   See the License for the specific language governing permissions and
 16   limitations under the License.
 17 -->
 18 <tomcat-users>
 19 <!--
 20   NOTE:  By default, no user is included in the "manager-gui" role required
 21   to operate the "/manager/html" web application.  If you wish to use this app,
 22   you must define such a user - the username and password are arbitrary.
 23 -->
 24 <!--
 25   NOTE:  The sample user and role entries below are wrapped in a comment
 26   and thus are ignored when reading this file. Do not forget to remove
 27   <!.. ..> that surrounds them.
 28 -->
 29 <!--
 30   <role rolename="tomcat"/>
 31   <role rolename="role1"/>
 32   <user username="tomcat" password="tomcat" roles="tomcat"/>
 33   <user username="both" password="tomcat" roles="tomcat,role1"/>
 34   <user username="role1" password="tomcat" roles="role1"/>
 35 -->
 36 
 37 <!-- The host manager webapp is restricted to users with role "admin" -->
 38 <!--<user name="tomcat" password="password" roles="admin" />-->
 39 <!-- The manager webapp is restricted to users with role "manager" -->
 40 <!--<user name="tomcat" password="password" roles="manager" />-->
 41 </tomcat-users>