忘備録

日々の調べ物をまとめる。アウトプットする。基本自分用。

【Python】websocketクライアントの実装

やっつけ。

環境

前提

  • websocket-clientパッケージをインストールしていること

websocket-client 0.35.0 : Python Package Index

Type “python setup.py install” or “pip install websocket-client” to install.

自分はpipでインストールしました。

  • 別途websocketサーバがあること

ソース

wsclient.py

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import websocket
import thread
import time

def on_message(ws, message):
    print "debug: called on_message"
    print message

def on_error(ws, error):
    print "debug: called on_error"
    print error

def on_close(ws):
    print "### closed ###"

def on_open(ws):
    def run(*args):
        print("debug: websocket is opened")

        while(True):
            line = sys.stdin.readline()
            if line != "":
                print "debug: sending value is " + line
                ws.send(line)

    thread.start_new_thread(run, ())


if __name__ == "__main__":

    param = sys.argv

    url = "デフォルトの接続先";

    if len(param) == 2:
        url = param[1]
        print "debug: param[1] is " + param[1]

    websocket.enableTrace(True)
    ws = websocket.WebSocketApp(url,
                              on_message = on_message,
                              on_error = on_error,
                              on_close = on_close)
    ws.on_open = on_open
    ws.run_forever()

使い方

スクリプトとして実行することを想定しています。

接続

ターミナルを開いて上記ファイルを実行

$ ./wsclient.py

接続先に誤りがなければ、以下のようにハンドシェイクのリクエストとレスポンスが帰ってきます。

正常

--- request header ---
GET /hoge HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: example.com:443
Origin: http://example.com
Sec-WebSocket-Key: JOtIu/5xaswrI2a5IRh/Wg==
Sec-WebSocket-Version: 13


-----------------------
--- response header ---
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Sec-WebSocket-Accept: CjFvo17ay0vliMi8Pdgm8Ve7LME=
Upgrade: WebSocket
-----------------------
debug: websocket is opened

接続先に誤りがある場合は以下のようになります。

接続先に誤りがある場合

$ ./wsclient.py ほげ
debug: param[1] is ほげ
debug: called on_error
url is invalid

ちなみにスクリプトの第一引数にURLを渡せるようにしてあります。渡さない場合はソースに直書きしてあるURLをデフォルトの接続先として接続するようになってます。

メッセージ送信

標準入力からメッセージを投げることができます。

適当にタイプして、エンターを叩くとタイプされたテキストをサーバに送信します。

ターミナル

--- response header ---
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Sec-WebSocket-Accept: CjFvo17ay0vliMi8Pdgm8Ve7LME=
Upgrade: WebSocket
-----------------------
debug: websocket is opened
this is test message
debug: sending value is this is test message

send: '\x81\x95J\x0c5\xad>d\\\xdejeF\x8d>iF\xd9jaP\xde9mR\xc8@'
hoge
debug: sending value is hoge

send: '\x81\x85\x9f"[\xea\xf7M<\x8f\x95'

分かりにくいですが、「this is test message」と「hoge」が入力した文字です。

使い道

あるのかな? 笑

自分はサクッとサーバのレスポンスをテストしたかったので作ってみました。

参考

websocket-client 0.35.0 : Python Package Index

Pythonで学ぶ 基礎からのプログラミング入門 (8) ユーザーからプログラムへの入力をする方法 | マイナビニュース

WebSocket サーバの実装とプロトコル解説 - Block Rockin’ Codes

【CentOS6】Let's Encryptを利用してApacheをHTTPS対応する

2016/12/02 追記

設定がめっちゃ簡単になってるみたい。

無償SSL/TLS証明書の Let’s Encrypt の設定が劇的に簡単になっていた | Webセキュリティの小部屋

こちらの記事を参考にした方が幸せになれそうです。

いちおう現在(2016/11/27)も、当方の記事の方法で証明書の発行はできてます。

環境

手順

git

Let's EncryptはGitHubから入手するので、入っていなかったらgitをインストールしておく。

$ yum install -y git
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package git.x86_64 0:1.7.1-3.el6_4.1 will be インストール
--> 依存性の処理をしています: perl-Git = 1.7.1-3.el6_4.1 のパッケージ: git-1.7.1-3.el6_4.1.x86_64
--> 依存性の処理をしています: rsync のパッケージ: git-1.7.1-3.el6_4.1.x86_64
--> 依存性の処理をしています: perl(Git) のパッケージ: git-1.7.1-3.el6_4.1.x86_64
--> 依存性の処理をしています: perl(Error) のパッケージ: git-1.7.1-3.el6_4.1.x86_64
--> トランザクションの確認を実行しています。
---> Package perl-Error.noarch 1:0.17015-4.el6 will be インストール
---> Package perl-Git.noarch 0:1.7.1-3.el6_4.1 will be インストール
---> Package rsync.x86_64 0:3.0.6-12.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================================================================================
 パッケージ                                     アーキテクチャ                             バージョン                                          リポジトリー                              容量
==============================================================================================================================================================================================
インストールしています:
 git                                            x86_64                                     1.7.1-3.el6_4.1                                     base                                     4.6 M
依存性関連でのインストールをします。:
 perl-Error                                     noarch                                     1:0.17015-4.el6                                     base                                      29 k
 perl-Git                                       noarch                                     1.7.1-3.el6_4.1                                     base                                      28 k
 rsync                                          x86_64                                     3.0.6-12.el6                                        base                                     335 k

トランザクションの要約
==============================================================================================================================================================================================
インストール         4 パッケージ

総ダウンロード容量: 5.0 M
インストール済み容量: 15 M
パッケージをダウンロードしています:
(1/4): git-1.7.1-3.el6_4.1.x86_64.rpm                                                                                                                                  | 4.6 MB     00:01     
(2/4): perl-Error-0.17015-4.el6.noarch.rpm                                                                                                                             |  29 kB     00:00     
(3/4): perl-Git-1.7.1-3.el6_4.1.noarch.rpm                                                                                                                             |  28 kB     00:00     
(4/4): rsync-3.0.6-12.el6.x86_64.rpm                                                                                                                                   | 335 kB     00:00     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                                                          1.8 MB/s | 5.0 MB     00:02     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : 1:perl-Error-0.17015-4.el6.noarch                                                                                                                             1/4 
  インストールしています  : rsync-3.0.6-12.el6.x86_64                                                                                                                                     2/4 
  インストールしています  : perl-Git-1.7.1-3.el6_4.1.noarch                                                                                                                               3/4 
  インストールしています  : git-1.7.1-3.el6_4.1.x86_64                                                                                                                                    4/4 
  Verifying               : git-1.7.1-3.el6_4.1.x86_64                                                                                                                                    1/4 
  Verifying               : perl-Git-1.7.1-3.el6_4.1.noarch                                                                                                                               2/4 
  Verifying               : 1:perl-Error-0.17015-4.el6.noarch                                                                                                                             3/4 
  Verifying               : rsync-3.0.6-12.el6.x86_64                                                                                                                                     4/4 

インストール:
  git.x86_64 0:1.7.1-3.el6_4.1                                                                                                                                                                

依存性関連をインストールしました:
  perl-Error.noarch 1:0.17015-4.el6                                perl-Git.noarch 0:1.7.1-3.el6_4.1                                rsync.x86_64 0:3.0.6-12.el6                               

完了しました!

python2.7

Let's Encrypt がサポートするpythonのバージョンは2.7なのですが、CentOS6.x系の標準パッケージではpython2.6がデフォルトとなっています。

というわけで、python2.7はSoftwareCollections(SCL)から入手する必要があります。

SCLリポジトリの追加

# 
$ yum install centos-release-SCL
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package centos-release-SCL.x86_64 10:6-5.el6.centos will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================================================================================
 パッケージ                                          アーキテクチャ                          バージョン                                         リポジトリー                             容量
==============================================================================================================================================================================================
インストールしています:
 centos-release-SCL                                  x86_64                                  10:6-5.el6.centos                                  extras                                  3.9 k

トランザクションの要約
==============================================================================================================================================================================================
インストール         1 パッケージ

総ダウンロード容量: 3.9 k
インストール済み容量: 453  
これでいいですか? [y/N]y
パッケージをダウンロードしています:
centos-release-SCL-6-5.el6.centos.x86_64.rpm                                                                                                                           | 3.9 kB     00:00     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : 10:centos-release-SCL-6-5.el6.centos.x86_64                                                                                                                   1/1 
  Verifying               : 10:centos-release-SCL-6-5.el6.centos.x86_64                                                                                                                   1/1 

インストール:
  centos-release-SCL.x86_64 10:6-5.el6.centos                                                                                                                                                 

完了しました!

python2.7のインストール

$ yum install -y python27 python27-python-devel python27-python-setuptools python27-python-tools python27-python-virtualenv
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package python27.x86_64 0:1.1-16.el6.centos.alt will be インストール
--> 依存性の処理をしています: python27-python-werkzeug のパッケージ: python27-1.1-16.el6.centos.alt.x86_64
--> 依存性の処理をしています: python27-python-sqlalchemy のパッケージ: python27-1.1-16.el6.centos.alt.x86_64
--> 依存性の処理をしています: python27-python-sphinx のパッケージ: python27-1.1-16.el6.centos.alt.x86_64
--> 依存性の処理をしています: python27-python-simplejson のパッケージ: python27-1.1-16.el6.centos.alt.x86_64
--> 依存性の処理をしています: python27-python-nose のパッケージ: python27-1.1-16.el6.centos.alt.x86_64
--> 依存性の処理をしています: python27-python-jinja2 のパッケージ: python27-1.1-16.el6.centos.alt.x86_64
--> 依存性の処理をしています: python27-python のパッケージ: python27-1.1-16.el6.centos.alt.x86_64
---> Package python27-python-devel.x86_64 0:2.7.5-10.el6.centos.alt will be インストール
--> 依存性の処理をしています: libpython2.7.so.1.0()(64bit) のパッケージ: python27-python-devel-2.7.5-10.el6.centos.alt.x86_64
---> Package python27-python-setuptools.noarch 0:0.9.8-2.el6.centos.alt will be インストール
---> Package python27-python-tools.x86_64 0:2.7.5-10.el6.centos.alt will be インストール
--> 依存性の処理をしています: python27-tkinter = 2.7.5-10.el6.centos.alt のパッケージ: python27-python-tools-2.7.5-10.el6.centos.alt.x86_64
---> Package python27-python-virtualenv.noarch 0:1.10.1-2.el6.centos.alt will be インストール
--> トランザクションの確認を実行しています。
---> Package python27-python.x86_64 0:2.7.5-10.el6.centos.alt will be インストール
--> 依存性の処理をしています: python27-runtime のパッケージ: python27-python-2.7.5-10.el6.centos.alt.x86_64
---> Package python27-python-jinja2.noarch 0:2.6-10.el6.centos.alt will be インストール
--> 依存性の処理をしています: python27-python-babel >= 0.8 のパッケージ: python27-python-jinja2-2.6-10.el6.centos.alt.noarch
--> 依存性の処理をしています: python27-python-markupsafe のパッケージ: python27-python-jinja2-2.6-10.el6.centos.alt.noarch
---> Package python27-python-libs.x86_64 0:2.7.5-10.el6.centos.alt will be インストール
---> Package python27-python-nose.noarch 0:1.3.0-1.el6.centos.alt will be インストール
---> Package python27-python-simplejson.x86_64 0:3.2.0-1.el6.centos.alt will be インストール
---> Package python27-python-sphinx.noarch 0:1.1.3-7.el6.centos.alt will be インストール
--> 依存性の処理をしています: python27-python-pygments のパッケージ: python27-python-sphinx-1.1.3-7.el6.centos.alt.noarch
--> 依存性の処理をしています: python27-python-docutils のパッケージ: python27-python-sphinx-1.1.3-7.el6.centos.alt.noarch
---> Package python27-python-sqlalchemy.x86_64 0:0.7.9-3.el6.centos.alt will be インストール
---> Package python27-python-werkzeug.noarch 0:0.8.3-5.el6.centos.alt will be インストール
---> Package python27-tkinter.x86_64 0:2.7.5-10.el6.centos.alt will be インストール
--> トランザクションの確認を実行しています。
---> Package python27-python-babel.noarch 0:0.9.6-7.el6.centos.alt will be インストール
---> Package python27-python-docutils.noarch 0:0.11-1.el6.centos.alt will be インストール
---> Package python27-python-markupsafe.x86_64 0:0.11-11.el6.centos.alt will be インストール
---> Package python27-python-pygments.noarch 0:1.5-2.el6.centos.alt will be インストール
---> Package python27-runtime.x86_64 0:1.1-16.el6.centos.alt will be インストール
--> 依存性の処理をしています: scl-utils のパッケージ: python27-runtime-1.1-16.el6.centos.alt.x86_64
--> トランザクションの確認を実行しています。
---> Package scl-utils.x86_64 0:20120927-27.el6_6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================
 パッケージ                               アーキテクチャ       バージョン                            リポジトリー        容量
==============================================================================================================================
インストールしています:
 python27                                 x86_64               1.1-16.el6.centos.alt                 scl                4.7 k
 python27-python-devel                    x86_64               2.7.5-10.el6.centos.alt               scl                386 k
 python27-python-setuptools               noarch               0.9.8-2.el6.centos.alt                scl                423 k
 python27-python-tools                    x86_64               2.7.5-10.el6.centos.alt               scl                877 k
 python27-python-virtualenv               noarch               1.10.1-2.el6.centos.alt               scl                1.4 M
依存性関連でのインストールをします。:
 python27-python                          x86_64               2.7.5-10.el6.centos.alt               scl                 80 k
 python27-python-babel                    noarch               0.9.6-7.el6.centos.alt                scl                1.4 M
 python27-python-docutils                 noarch               0.11-1.el6.centos.alt                 scl                1.6 M
 python27-python-jinja2                   noarch               2.6-10.el6.centos.alt                 scl                550 k
 python27-python-libs                     x86_64               2.7.5-10.el6.centos.alt               scl                5.5 M
 python27-python-markupsafe               x86_64               0.11-11.el6.centos.alt                scl                 25 k
 python27-python-nose                     noarch               1.3.0-1.el6.centos.alt                scl                290 k
 python27-python-pygments                 noarch               1.5-2.el6.centos.alt                  scl                802 k
 python27-python-simplejson               x86_64               3.2.0-1.el6.centos.alt                scl                174 k
 python27-python-sphinx                   noarch               1.1.3-7.el6.centos.alt                scl                1.1 M
 python27-python-sqlalchemy               x86_64               0.7.9-3.el6.centos.alt                scl                2.1 M
 python27-python-werkzeug                 noarch               0.8.3-5.el6.centos.alt                scl                556 k
 python27-runtime                         x86_64               1.1-16.el6.centos.alt                 scl                1.0 M
 python27-tkinter                         x86_64               2.7.5-10.el6.centos.alt               scl                333 k
 scl-utils                                x86_64               20120927-27.el6_6                     base                22 k

トランザクションの要約
==============================================================================================================================
インストール        20 パッケージ

総ダウンロード容量: 19 M
インストール済み容量: 71 M
パッケージをダウンロードしています:
(1/20): python27-1.1-16.el6.centos.alt.x86_64.rpm                                                      | 4.7 kB     00:00     
(2/20): python27-python-2.7.5-10.el6.centos.alt.x86_64.rpm                                             |  80 kB     00:01     
(3/20): python27-python-babel-0.9.6-7.el6.centos.alt.noarch.rpm                                        | 1.4 MB     00:05     
(4/20): python27-python-devel-2.7.5-10.el6.centos.alt.x86_64.rpm                                       | 386 kB     00:00     
(5/20): python27-python-docutils-0.11-1.el6.centos.alt.noarch.rpm                                      | 1.6 MB     00:01     
(6/20): python27-python-jinja2-2.6-10.el6.centos.alt.noarch.rpm                                        | 550 kB     00:00     
(7/20): python27-python-libs-2.7.5-10.el6.centos.alt.x86_64.rpm                                        | 5.5 MB     00:05     
(8/20): python27-python-markupsafe-0.11-11.el6.centos.alt.x86_64.rpm                                   |  25 kB     00:00     
(9/20): python27-python-nose-1.3.0-1.el6.centos.alt.noarch.rpm                                         | 290 kB     00:00     
(10/20): python27-python-pygments-1.5-2.el6.centos.alt.noarch.rpm                                      | 802 kB     00:00     
(11/20): python27-python-setuptools-0.9.8-2.el6.centos.alt.noarch.rpm                                  | 423 kB     00:00     
(12/20): python27-python-simplejson-3.2.0-1.el6.centos.alt.x86_64.rpm                                  | 174 kB     00:00     
(13/20): python27-python-sphinx-1.1.3-7.el6.centos.alt.noarch.rpm                                      | 1.1 MB     00:00     
(14/20): python27-python-sqlalchemy-0.7.9-3.el6.centos.alt.x86_64.rpm                                  | 2.1 MB     00:01     
(15/20): python27-python-tools-2.7.5-10.el6.centos.alt.x86_64.rpm                                      | 877 kB     00:00     
(16/20): python27-python-virtualenv-1.10.1-2.el6.centos.alt.noarch.rpm                                 | 1.4 MB     00:00     
(17/20): python27-python-werkzeug-0.8.3-5.el6.centos.alt.noarch.rpm                                    | 556 kB     00:00     
(18/20): python27-runtime-1.1-16.el6.centos.alt.x86_64.rpm                                             | 1.0 MB     00:00     
(19/20): python27-tkinter-2.7.5-10.el6.centos.alt.x86_64.rpm                                           | 333 kB     00:00     
(20/20): scl-utils-20120927-27.el6_6.x86_64.rpm                                                        |  22 kB     00:00     
------------------------------------------------------------------------------------------------------------------------------
合計                                                                                          653 kB/s |  19 MB     00:29     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : scl-utils-20120927-27.el6_6.x86_64                                                           1/20 
  インストールしています  : python27-runtime-1.1-16.el6.centos.alt.x86_64                                                2/20 
  インストールしています  : python27-python-libs-2.7.5-10.el6.centos.alt.x86_64                                          3/20 
  インストールしています  : python27-python-2.7.5-10.el6.centos.alt.x86_64                                               4/20 
  インストールしています  : python27-python-setuptools-0.9.8-2.el6.centos.alt.noarch                                     5/20 
  インストールしています  : python27-python-pygments-1.5-2.el6.centos.alt.noarch                                         6/20 
  インストールしています  : python27-python-nose-1.3.0-1.el6.centos.alt.noarch                                           7/20 
  インストールしています  : python27-python-werkzeug-0.8.3-5.el6.centos.alt.noarch                                       8/20 
  インストールしています  : python27-python-docutils-0.11-1.el6.centos.alt.noarch                                        9/20 
  インストールしています  : python27-python-sqlalchemy-0.7.9-3.el6.centos.alt.x86_64                                    10/20 
  インストールしています  : python27-python-simplejson-3.2.0-1.el6.centos.alt.x86_64                                    11/20 
  インストールしています  : python27-tkinter-2.7.5-10.el6.centos.alt.x86_64                                             12/20 
  インストールしています  : python27-python-markupsafe-0.11-11.el6.centos.alt.x86_64                                    13/20 
  インストールしています  : python27-python-devel-2.7.5-10.el6.centos.alt.x86_64                                        14/20 
  インストールしています  : python27-python-virtualenv-1.10.1-2.el6.centos.alt.noarch                                   15/20 
  インストールしています  : python27-python-babel-0.9.6-7.el6.centos.alt.noarch                                         16/20 
  インストールしています  : python27-python-jinja2-2.6-10.el6.centos.alt.noarch                                         17/20 
  インストールしています  : python27-python-sphinx-1.1.3-7.el6.centos.alt.noarch                                        18/20 
  インストールしています  : python27-1.1-16.el6.centos.alt.x86_64                                                       19/20 
  インストールしています  : python27-python-tools-2.7.5-10.el6.centos.alt.x86_64                                        20/20 
  Verifying               : python27-python-sphinx-1.1.3-7.el6.centos.alt.noarch                                         1/20 
  Verifying               : python27-python-werkzeug-0.8.3-5.el6.centos.alt.noarch                                       2/20 
  Verifying               : python27-python-pygments-1.5-2.el6.centos.alt.noarch                                         3/20 
  Verifying               : python27-python-nose-1.3.0-1.el6.centos.alt.noarch                                           4/20 
  Verifying               : python27-python-virtualenv-1.10.1-2.el6.centos.alt.noarch                                    5/20 
  Verifying               : python27-python-docutils-0.11-1.el6.centos.alt.noarch                                        6/20 
  Verifying               : python27-python-sqlalchemy-0.7.9-3.el6.centos.alt.x86_64                                     7/20 
  Verifying               : python27-python-setuptools-0.9.8-2.el6.centos.alt.noarch                                     8/20 
  Verifying               : python27-python-tools-2.7.5-10.el6.centos.alt.x86_64                                         9/20 
  Verifying               : python27-runtime-1.1-16.el6.centos.alt.x86_64                                               10/20 
  Verifying               : python27-python-simplejson-3.2.0-1.el6.centos.alt.x86_64                                    11/20 
  Verifying               : python27-tkinter-2.7.5-10.el6.centos.alt.x86_64                                             12/20 
  Verifying               : python27-python-markupsafe-0.11-11.el6.centos.alt.x86_64                                    13/20 
  Verifying               : scl-utils-20120927-27.el6_6.x86_64                                                          14/20 
  Verifying               : python27-python-libs-2.7.5-10.el6.centos.alt.x86_64                                         15/20 
  Verifying               : python27-python-devel-2.7.5-10.el6.centos.alt.x86_64                                        16/20 
  Verifying               : python27-python-2.7.5-10.el6.centos.alt.x86_64                                              17/20 
  Verifying               : python27-1.1-16.el6.centos.alt.x86_64                                                       18/20 
  Verifying               : python27-python-babel-0.9.6-7.el6.centos.alt.noarch                                         19/20 
  Verifying               : python27-python-jinja2-2.6-10.el6.centos.alt.noarch                                         20/20 

インストール:
  python27.x86_64 0:1.1-16.el6.centos.alt                          python27-python-devel.x86_64 0:2.7.5-10.el6.centos.alt     
  python27-python-setuptools.noarch 0:0.9.8-2.el6.centos.alt       python27-python-tools.x86_64 0:2.7.5-10.el6.centos.alt     
  python27-python-virtualenv.noarch 0:1.10.1-2.el6.centos.alt     

依存性関連をインストールしました:
  python27-python.x86_64 0:2.7.5-10.el6.centos.alt              python27-python-babel.noarch 0:0.9.6-7.el6.centos.alt        
  python27-python-docutils.noarch 0:0.11-1.el6.centos.alt       python27-python-jinja2.noarch 0:2.6-10.el6.centos.alt        
  python27-python-libs.x86_64 0:2.7.5-10.el6.centos.alt         python27-python-markupsafe.x86_64 0:0.11-11.el6.centos.alt   
  python27-python-nose.noarch 0:1.3.0-1.el6.centos.alt          python27-python-pygments.noarch 0:1.5-2.el6.centos.alt       
  python27-python-simplejson.x86_64 0:3.2.0-1.el6.centos.alt    python27-python-sphinx.noarch 0:1.1.3-7.el6.centos.alt       
  python27-python-sqlalchemy.x86_64 0:0.7.9-3.el6.centos.alt    python27-python-werkzeug.noarch 0:0.8.3-5.el6.centos.alt     
  python27-runtime.x86_64 0:1.1-16.el6.centos.alt               python27-tkinter.x86_64 0:2.7.5-10.el6.centos.alt            
  scl-utils.x86_64 0:20120927-27.el6_6                         

完了しました!

ファイアウォール

httpsは443ポートを利用するため、開けておきます。

$ iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

iptables再起動

$ service iptables restart
iptables: チェインをポリシー ACCEPT へ設定中filter         [  OK  ]
iptables: ファイアウォールルールを消去中:                  [  OK  ]
iptables: モジュールを取り外し中:                          [  OK  ]
iptables: ファイアウォールルールを適用中:                  [  OK  ]

確認

$ iptables -L -n | grep 443
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:443 

Let's Encrypt

インストール

GitHubから入手します。

# インストールするディレクトリは任意だが適当と思われる/usr/local/に入れる
$ cd /usr/local/
$ git clone https://github.com/letsencrypt/letsencrypt
Initialized empty Git repository in /usr/local/letsencrypt/.git/
remote: Counting objects: 32215, done.
remote: Compressing objects: 100% (138/138), done.
remote: Total 32215 (delta 79), reused 0 (delta 0), pack-reused 32077
Receiving objects: 100% (32215/32215), 8.38 MiB | 1.45 MiB/s, done.
Resolving deltas: 100% (22799/22799), done.
$ cd letsencrypt

依存パッケージのインストール

「letsencrypt-auto」というスクリプトがあり、実行するとsslpythonといった依存パッケージをインストールしてくれる。

 ./letsencrypt-auto --help
Bootstrapping dependencies for RedHat-based OSes...
yum is /usr/bin/yum
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
パッケージ python-2.6.6-64.el6.x86_64 はインストール済みか最新バージョンです
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package python-devel.x86_64 0:2.6.6-64.el6 will be インストール
---> Package python-pip.noarch 0:7.1.0-1.el6 will be インストール
--> 依存性の処理をしています: python-setuptools のパッケージ: python-pip-7.1.0-1.el6.noarch
---> Package python-tools.x86_64 0:2.6.6-64.el6 will be インストール
--> 依存性の処理をしています: tkinter = 2.6.6-64.el6 のパッケージ: python-tools-2.6.6-64.el6.x86_64
---> Package python-virtualenv.noarch 0:1.10.1-1.el6 will be インストール
--> トランザクションの確認を実行しています。
---> Package python-setuptools.noarch 0:0.6.10-3.el6 will be インストール
---> Package tkinter.x86_64 0:2.6.6-64.el6 will be インストール
--> 依存性の処理をしています: libtk8.5.so()(64bit) のパッケージ: tkinter-2.6.6-64.el6.x86_64
--> 依存性の処理をしています: libtcl8.5.so()(64bit) のパッケージ: tkinter-2.6.6-64.el6.x86_64
--> 依存性の処理をしています: libTix.so()(64bit) のパッケージ: tkinter-2.6.6-64.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package tcl.x86_64 1:8.5.7-6.el6 will be インストール
---> Package tix.x86_64 1:8.4.3-5.el6 will be インストール
---> Package tk.x86_64 1:8.5.7-5.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================
 パッケージ                          アーキテクチャ           バージョン                         リポジトリー            容量
==============================================================================================================================
インストールしています:
 python-devel                        x86_64                   2.6.6-64.el6                       base                   172 k
 python-pip                          noarch                   7.1.0-1.el6                        epel                   1.5 M
 python-tools                        x86_64                   2.6.6-64.el6                       base                   870 k
 python-virtualenv                   noarch                   1.10.1-1.el6                       epel                   1.3 M
依存性関連でのインストールをします。:
 python-setuptools                   noarch                   0.6.10-3.el6                       base                   336 k
 tcl                                 x86_64                   1:8.5.7-6.el6                      base                   1.9 M
 tix                                 x86_64                   1:8.4.3-5.el6                      base                   252 k
 tk                                  x86_64                   1:8.5.7-5.el6                      base                   1.4 M
 tkinter                             x86_64                   2.6.6-64.el6                       base                   257 k

トランザクションの要約
==============================================================================================================================
インストール         9 パッケージ

総ダウンロード容量: 8.0 M
インストール済み容量: 22 M
パッケージをダウンロードしています:
(1/9): python-devel-2.6.6-64.el6.x86_64.rpm                                                            | 172 kB     00:00     
(2/9): python-pip-7.1.0-1.el6.noarch.rpm                                                               | 1.5 MB     00:01     
(3/9): python-setuptools-0.6.10-3.el6.noarch.rpm                                                       | 336 kB     00:00     
(4/9): python-tools-2.6.6-64.el6.x86_64.rpm                                                            | 870 kB     00:01     
(5/9): python-virtualenv-1.10.1-1.el6.noarch.rpm                                                       | 1.3 MB     00:01     
(6/9): tcl-8.5.7-6.el6.x86_64.rpm                                                                      | 1.9 MB     00:01     
(7/9): tix-8.4.3-5.el6.x86_64.rpm                                                                      | 252 kB     00:00     
(8/9): tk-8.5.7-5.el6.x86_64.rpm                                                                       | 1.4 MB     00:01     
(9/9): tkinter-2.6.6-64.el6.x86_64.rpm                                                                 | 257 kB     00:00     
------------------------------------------------------------------------------------------------------------------------------
合計                                                                                          770 kB/s | 8.0 MB     00:10     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : 1:tcl-8.5.7-6.el6.x86_64                                                                      1/9 
  インストールしています  : 1:tk-8.5.7-5.el6.x86_64                                                                       2/9 
  インストールしています  : python-setuptools-0.6.10-3.el6.noarch                                                         3/9 
  インストールしています  : 1:tix-8.4.3-5.el6.x86_64                                                                      4/9 
  インストールしています  : tkinter-2.6.6-64.el6.x86_64                                                                   5/9 
  インストールしています  : python-devel-2.6.6-64.el6.x86_64                                                              6/9 
  インストールしています  : python-virtualenv-1.10.1-1.el6.noarch                                                         7/9 
  インストールしています  : python-tools-2.6.6-64.el6.x86_64                                                              8/9 
  インストールしています  : python-pip-7.1.0-1.el6.noarch                                                                 9/9 
  Verifying               : python-devel-2.6.6-64.el6.x86_64                                                              1/9 
  Verifying               : python-pip-7.1.0-1.el6.noarch                                                                 2/9 
  Verifying               : 1:tix-8.4.3-5.el6.x86_64                                                                      3/9 
  Verifying               : python-tools-2.6.6-64.el6.x86_64                                                              4/9 
  Verifying               : python-virtualenv-1.10.1-1.el6.noarch                                                         5/9 
  Verifying               : 1:tcl-8.5.7-6.el6.x86_64                                                                      6/9 
  Verifying               : 1:tk-8.5.7-5.el6.x86_64                                                                       7/9 
  Verifying               : python-setuptools-0.6.10-3.el6.noarch                                                         8/9 
  Verifying               : tkinter-2.6.6-64.el6.x86_64                                                                   9/9 

インストール:
  python-devel.x86_64 0:2.6.6-64.el6            python-pip.noarch 0:7.1.0-1.el6       python-tools.x86_64 0:2.6.6-64.el6      
  python-virtualenv.noarch 0:1.10.1-1.el6      

依存性関連をインストールしました:
  python-setuptools.noarch 0:0.6.10-3.el6   tcl.x86_64 1:8.5.7-6.el6   tix.x86_64 1:8.4.3-5.el6   tk.x86_64 1:8.5.7-5.el6  
  tkinter.x86_64 0:2.6.6-64.el6            

完了しました!
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
パッケージ openssl-1.0.1e-42.el6_7.2.x86_64 はインストール済みか最新バージョンです
パッケージ ca-certificates-2015.2.4-65.0.1.el6_6.noarch はインストール済みか最新バージョンです
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package augeas-libs.x86_64 0:1.0.0-10.el6 will be インストール
---> Package dialog.x86_64 0:1.1-9.20080819.1.el6 will be インストール
---> Package gcc.x86_64 0:4.4.7-16.el6 will be インストール
--> 依存性の処理をしています: libgomp = 4.4.7-16.el6 のパッケージ: gcc-4.4.7-16.el6.x86_64
--> 依存性の処理をしています: cpp = 4.4.7-16.el6 のパッケージ: gcc-4.4.7-16.el6.x86_64
--> 依存性の処理をしています: glibc-devel >= 2.2.90-12 のパッケージ: gcc-4.4.7-16.el6.x86_64
--> 依存性の処理をしています: cloog-ppl >= 0.15 のパッケージ: gcc-4.4.7-16.el6.x86_64
--> 依存性の処理をしています: libgomp.so.1()(64bit) のパッケージ: gcc-4.4.7-16.el6.x86_64
---> Package libffi-devel.x86_64 0:3.0.5-3.2.el6 will be インストール
---> Package openssl-devel.x86_64 0:1.0.1e-42.el6_7.2 will be インストール
--> 依存性の処理をしています: zlib-devel のパッケージ: openssl-devel-1.0.1e-42.el6_7.2.x86_64
--> 依存性の処理をしています: krb5-devel のパッケージ: openssl-devel-1.0.1e-42.el6_7.2.x86_64
---> Package redhat-rpm-config.noarch 0:9.0.3-44.el6.centos will be インストール
--> トランザクションの確認を実行しています。
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be インストール
--> 依存性の処理をしています: libppl_c.so.2()(64bit) のパッケージ: cloog-ppl-0.15.7-1.2.el6.x86_64
--> 依存性の処理をしています: libppl.so.7()(64bit) のパッケージ: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-16.el6 will be インストール
--> 依存性の処理をしています: libmpfr.so.1()(64bit) のパッケージ: cpp-4.4.7-16.el6.x86_64
---> Package glibc-devel.x86_64 0:2.12-1.166.el6_7.7 will be インストール
--> 依存性の処理をしています: glibc-headers = 2.12-1.166.el6_7.7 のパッケージ: glibc-devel-2.12-1.166.el6_7.7.x86_64
--> 依存性の処理をしています: glibc-headers のパッケージ: glibc-devel-2.12-1.166.el6_7.7.x86_64
---> Package krb5-devel.x86_64 0:1.10.3-42.el6 will be インストール
--> 依存性の処理をしています: libselinux-devel のパッケージ: krb5-devel-1.10.3-42.el6.x86_64
--> 依存性の処理をしています: libcom_err-devel のパッケージ: krb5-devel-1.10.3-42.el6.x86_64
--> 依存性の処理をしています: keyutils-libs-devel のパッケージ: krb5-devel-1.10.3-42.el6.x86_64
---> Package libgomp.x86_64 0:4.4.7-16.el6 will be インストール
---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be インストール
--> トランザクションの確認を実行しています。
---> Package glibc-headers.x86_64 0:2.12-1.166.el6_7.7 will be インストール
--> 依存性の処理をしています: kernel-headers >= 2.2.1 のパッケージ: glibc-headers-2.12-1.166.el6_7.7.x86_64
--> 依存性の処理をしています: kernel-headers のパッケージ: glibc-headers-2.12-1.166.el6_7.7.x86_64
---> Package keyutils-libs-devel.x86_64 0:1.4-5.el6 will be インストール
---> Package libcom_err-devel.x86_64 0:1.41.12-22.el6 will be インストール
---> Package libselinux-devel.x86_64 0:2.0.94-5.8.el6 will be インストール
--> 依存性の処理をしています: libsepol-devel >= 2.0.32-1 のパッケージ: libselinux-devel-2.0.94-5.8.el6.x86_64
--> 依存性の処理をしています: pkgconfig(libsepol) のパッケージ: libselinux-devel-2.0.94-5.8.el6.x86_64
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be インストール
---> Package ppl.x86_64 0:0.10.2-11.el6 will be インストール
--> トランザクションの確認を実行しています。
---> Package kernel-headers.x86_64 0:2.6.32-573.18.1.el6 will be インストール
---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================
 パッケージ                         アーキテクチャ        バージョン                             リポジトリー            容量
==============================================================================================================================
インストールしています:
 augeas-libs                        x86_64                1.0.0-10.el6                           base                   314 k
 dialog                             x86_64                1.1-9.20080819.1.el6                   base                   197 k
 gcc                                x86_64                4.4.7-16.el6                           base                    10 M
 libffi-devel                       x86_64                3.0.5-3.2.el6                          base                    18 k
 openssl-devel                      x86_64                1.0.1e-42.el6_7.2                      updates                1.2 M
 redhat-rpm-config                  noarch                9.0.3-44.el6.centos                    base                    59 k
依存性関連でのインストールをします。:
 cloog-ppl                          x86_64                0.15.7-1.2.el6                         base                    93 k
 cpp                                x86_64                4.4.7-16.el6                           base                   3.7 M
 glibc-devel                        x86_64                2.12-1.166.el6_7.7                     updates                986 k
 glibc-headers                      x86_64                2.12-1.166.el6_7.7                     updates                615 k
 kernel-headers                     x86_64                2.6.32-573.18.1.el6                    updates                3.9 M
 keyutils-libs-devel                x86_64                1.4-5.el6                              base                    29 k
 krb5-devel                         x86_64                1.10.3-42.el6                          base                   502 k
 libcom_err-devel                   x86_64                1.41.12-22.el6                         base                    33 k
 libgomp                            x86_64                4.4.7-16.el6                           base                   134 k
 libselinux-devel                   x86_64                2.0.94-5.8.el6                         base                   137 k
 libsepol-devel                     x86_64                2.0.41-4.el6                           base                    64 k
 mpfr                               x86_64                2.4.1-6.el6                            base                   157 k
 ppl                                x86_64                0.10.2-11.el6                          base                   1.3 M
 zlib-devel                         x86_64                1.2.3-29.el6                           base                    44 k

トランザクションの要約
==============================================================================================================================
インストール        20 パッケージ

総ダウンロード容量: 23 M
インストール済み容量: 45 M
パッケージをダウンロードしています:
(1/20): augeas-libs-1.0.0-10.el6.x86_64.rpm                                                            | 314 kB     00:00     
(2/20): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm                                                            |  93 kB     00:00     
(3/20): cpp-4.4.7-16.el6.x86_64.rpm                                                                    | 3.7 MB     00:01     
(4/20): dialog-1.1-9.20080819.1.el6.x86_64.rpm                                                         | 197 kB     00:00     
(5/20): gcc-4.4.7-16.el6.x86_64.rpm                                                                    |  10 MB     00:03     
(6/20): glibc-devel-2.12-1.166.el6_7.7.x86_64.rpm                                                      | 986 kB     00:01     
(7/20): glibc-headers-2.12-1.166.el6_7.7.x86_64.rpm                                                    | 615 kB     00:00     
(8/20): kernel-headers-2.6.32-573.18.1.el6.x86_64.rpm                                                  | 3.9 MB     00:01     
(9/20): keyutils-libs-devel-1.4-5.el6.x86_64.rpm                                                       |  29 kB     00:00     
(10/20): krb5-devel-1.10.3-42.el6.x86_64.rpm                                                           | 502 kB     00:00     
(11/20): libcom_err-devel-1.41.12-22.el6.x86_64.rpm                                                    |  33 kB     00:00     
(12/20): libffi-devel-3.0.5-3.2.el6.x86_64.rpm                                                         |  18 kB     00:00     
(13/20): libgomp-4.4.7-16.el6.x86_64.rpm                                                               | 134 kB     00:00     
(14/20): libselinux-devel-2.0.94-5.8.el6.x86_64.rpm                                                    | 137 kB     00:00     
(15/20): libsepol-devel-2.0.41-4.el6.x86_64.rpm                                                        |  64 kB     00:00     
(16/20): mpfr-2.4.1-6.el6.x86_64.rpm                                                                   | 157 kB     00:00     
(17/20): openssl-devel-1.0.1e-42.el6_7.2.x86_64.rpm                                                    | 1.2 MB     00:01     
(18/20): ppl-0.10.2-11.el6.x86_64.rpm                                                                  | 1.3 MB     00:01     
(19/20): redhat-rpm-config-9.0.3-44.el6.centos.noarch.rpm                                              |  59 kB     00:00     
(20/20): zlib-devel-1.2.3-29.el6.x86_64.rpm                                                            |  44 kB     00:00     
------------------------------------------------------------------------------------------------------------------------------
合計                                                                                          1.3 MB/s |  23 MB     00:18     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : zlib-devel-1.2.3-29.el6.x86_64                                                               1/20 
  インストールしています  : libcom_err-devel-1.41.12-22.el6.x86_64                                                       2/20 
  インストールしています  : kernel-headers-2.6.32-573.18.1.el6.x86_64                                                    3/20 
  インストールしています  : glibc-headers-2.12-1.166.el6_7.7.x86_64                                                      4/20 
  インストールしています  : glibc-devel-2.12-1.166.el6_7.7.x86_64                                                        5/20 
  インストールしています  : mpfr-2.4.1-6.el6.x86_64                                                                      6/20 
  インストールしています  : cpp-4.4.7-16.el6.x86_64                                                                      7/20 
  インストールしています  : ppl-0.10.2-11.el6.x86_64                                                                     8/20 
  インストールしています  : cloog-ppl-0.15.7-1.2.el6.x86_64                                                              9/20 
  インストールしています  : libsepol-devel-2.0.41-4.el6.x86_64                                                          10/20 
  インストールしています  : libselinux-devel-2.0.94-5.8.el6.x86_64                                                      11/20 
  インストールしています  : keyutils-libs-devel-1.4-5.el6.x86_64                                                        12/20 
  インストールしています  : krb5-devel-1.10.3-42.el6.x86_64                                                             13/20 
  インストールしています  : libgomp-4.4.7-16.el6.x86_64                                                                 14/20 
  インストールしています  : gcc-4.4.7-16.el6.x86_64                                                                     15/20 
  インストールしています  : openssl-devel-1.0.1e-42.el6_7.2.x86_64                                                      16/20 
  インストールしています  : augeas-libs-1.0.0-10.el6.x86_64                                                             17/20 
  インストールしています  : redhat-rpm-config-9.0.3-44.el6.centos.noarch                                                18/20 
  インストールしています  : dialog-1.1-9.20080819.1.el6.x86_64                                                          19/20 
  インストールしています  : libffi-devel-3.0.5-3.2.el6.x86_64                                                           20/20 
  Verifying               : libgomp-4.4.7-16.el6.x86_64                                                                  1/20 
  Verifying               : keyutils-libs-devel-1.4-5.el6.x86_64                                                         2/20 
  Verifying               : libsepol-devel-2.0.41-4.el6.x86_64                                                           3/20 
  Verifying               : openssl-devel-1.0.1e-42.el6_7.2.x86_64                                                       4/20 
  Verifying               : ppl-0.10.2-11.el6.x86_64                                                                     5/20 
  Verifying               : krb5-devel-1.10.3-42.el6.x86_64                                                              6/20 
  Verifying               : gcc-4.4.7-16.el6.x86_64                                                                      7/20 
  Verifying               : mpfr-2.4.1-6.el6.x86_64                                                                      8/20 
  Verifying               : libffi-devel-3.0.5-3.2.el6.x86_64                                                            9/20 
  Verifying               : kernel-headers-2.6.32-573.18.1.el6.x86_64                                                   10/20 
  Verifying               : libselinux-devel-2.0.94-5.8.el6.x86_64                                                      11/20 
  Verifying               : dialog-1.1-9.20080819.1.el6.x86_64                                                          12/20 
  Verifying               : libcom_err-devel-1.41.12-22.el6.x86_64                                                      13/20 
  Verifying               : glibc-headers-2.12-1.166.el6_7.7.x86_64                                                     14/20 
  Verifying               : zlib-devel-1.2.3-29.el6.x86_64                                                              15/20 
  Verifying               : cpp-4.4.7-16.el6.x86_64                                                                     16/20 
  Verifying               : glibc-devel-2.12-1.166.el6_7.7.x86_64                                                       17/20 
  Verifying               : cloog-ppl-0.15.7-1.2.el6.x86_64                                                             18/20 
  Verifying               : redhat-rpm-config-9.0.3-44.el6.centos.noarch                                                19/20 
  Verifying               : augeas-libs-1.0.0-10.el6.x86_64                                                             20/20 

インストール:
  augeas-libs.x86_64 0:1.0.0-10.el6   dialog.x86_64 0:1.1-9.20080819.1.el6     gcc.x86_64 0:4.4.7-16.el6                     
  libffi-devel.x86_64 0:3.0.5-3.2.el6 openssl-devel.x86_64 0:1.0.1e-42.el6_7.2 redhat-rpm-config.noarch 0:9.0.3-44.el6.centos

依存性関連をインストールしました:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6                              cpp.x86_64 0:4.4.7-16.el6                                   
  glibc-devel.x86_64 0:2.12-1.166.el6_7.7                        glibc-headers.x86_64 0:2.12-1.166.el6_7.7                   
  kernel-headers.x86_64 0:2.6.32-573.18.1.el6                    keyutils-libs-devel.x86_64 0:1.4-5.el6                      
  krb5-devel.x86_64 0:1.10.3-42.el6                              libcom_err-devel.x86_64 0:1.41.12-22.el6                    
  libgomp.x86_64 0:4.4.7-16.el6                                  libselinux-devel.x86_64 0:2.0.94-5.8.el6                    
  libsepol-devel.x86_64 0:2.0.41-4.el6                           mpfr.x86_64 0:2.4.1-6.el6                                   
  ppl.x86_64 0:0.10.2-11.el6                                     zlib-devel.x86_64 0:1.2.3-29.el6                            

完了しました!
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package mod_ssl.x86_64 1:2.2.15-47.el6.centos.3 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================
 パッケージ               アーキテクチャ          バージョン                                   リポジトリー              容量
==============================================================================================================================
インストールしています:
 mod_ssl                  x86_64                  1:2.2.15-47.el6.centos.3                     updates                   95 k

トランザクションの要約
==============================================================================================================================
インストール         1 パッケージ

総ダウンロード容量: 95 k
インストール済み容量: 187 k
パッケージをダウンロードしています:
mod_ssl-2.2.15-47.el6.centos.3.x86_64.rpm                                                              |  95 kB     00:00     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : 1:mod_ssl-2.2.15-47.el6.centos.3.x86_64                                                       1/1 
  Verifying               : 1:mod_ssl-2.2.15-47.el6.centos.3.x86_64                                                       1/1 

インストール:
  mod_ssl.x86_64 1:2.2.15-47.el6.centos.3                                                                                     

完了しました!
Checking for new version...
Creating virtual environment...
Installing Python packages...
Requesting root privileges to run letsencrypt...
   /root/.local/share/letsencrypt/bin/letsencrypt --no-self-upgrade --help
/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:25: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python.
  DeprecationWarning

  letsencrypt-auto [SUBCOMMAND] [options] [-d domain] [-d domain] ...

The Let's Encrypt agent can obtain and install HTTPS/TLS/SSL certificates.  By
default, it will attempt to use a webserver both for obtaining and installing
the cert. Major SUBCOMMANDS are:

  (default) run        Obtain & install a cert in your current webserver
  certonly             Obtain cert, but do not install it (aka "auth")
  install              Install a previously obtained cert in a server
  renew                Renew previously obtained certs that are near expiry
  revoke               Revoke a previously obtained certificate
  rollback             Rollback server configuration changes made during install
  config_changes       Show changes made to server config during installation
  plugins              Display information about installed plugins

Choice of server plugins for obtaining and installing cert:

  --apache          Use the Apache plugin for authentication & installation
  --standalone      Run a standalone webserver for authentication
  (nginx support is experimental, buggy, and not installed by default)
  --webroot         Place files in a server's webroot folder for authentication

OR use different plugins to obtain (authenticate) the cert and then install it:

  --authenticator standalone --installer apache

More detailed help:

  -h, --help [topic]    print this message, or detailed help on a topic;
                        the available topics are:

   all, automation, paths, security, testing, or any of the subcommands or
   plugins (certonly, install, nginx, apache, standalone, webroot, etc)

証明書の発行

 ./letsencrypt-auto certonly --webroot --webroot-path /home/apache/vhost/example/html \
-d example.co.jp -d www.example.co.jp \
--agree-tos -m hoge@example.co.jp

Checking for new version...
Creating virtual environment...
Installing Python packages...
Requesting root privileges to run letsencrypt...
   /root/.local/share/letsencrypt/bin/letsencrypt --no-self-upgrade certonly --webroot --webroot-path /home/apache/vhost/example/html -d example.co.jp -d www.example.co.jp --agree-tos -m hoge@example.co.jp
/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:25: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python.
  DeprecationWarning
Version: 1.1-20080819
Version: 1.1-20080819

IMPORTANT NOTES:
 - If you lose your account credentials, you can recover through
   e-mails sent to example@co.jp.
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/example.co.jp/fullchain.pem. Your cert
   will expire on 2016-05-29. To obtain a new version of the
   certificate in the future, simply run Let's Encrypt again.
 - Your account credentials have been saved in your Let's Encrypt
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Let's
   Encrypt so making regular backups of this folder is ideal.
 - If you like Let's Encrypt, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

証明書の生成が正常に終了すると

/etc/letsencrypt/live/example.co.jp/ 配下に証明書(のリンク)が生成されている。

$  ls -la /etc/letsencrypt/live/example.co.jp/
合計 8
drwxr-xr-x. 2 root root 4096  31 07:37 2016 .
drwx------. 3 root root 4096  31 07:37 2016 ..
lrwxrwxrwx. 1 root root   40  31 07:37 2016 cert.pem -> ../../archive/example.co.jp/cert1.pem # 証明書
lrwxrwxrwx. 1 root root   41  31 07:37 2016 chain.pem -> ../../archive/example.co.jp/chain1.pem # 証明書チェーン
lrwxrwxrwx. 1 root root   45  31 07:37 2016 fullchain.pem -> ../../archive/example.co.jp/fullchain1.pem # 証明書(cert.pemとchain.pemをまとめたもの)
lrwxrwxrwx. 1 root root   43  31 07:37 2016 privkey.pem -> ../../archive/example.co.jp/privkey1.pemsh # 秘密鍵

Apachehttps対応

ssl.confの設定

/etc/httpd/conf.d/ssl.conf

#
# When we also provide SSL we have to listen to the
# the HTTPS port in addition.
#
Listen 443 https

##
##  SSL Global Context
##
##  All SSL configuration in this context applies both to
##  the main server and all SSL-enabled virtual hosts.
##

#   Pass Phrase Dialog:
#   Configure the pass phrase gathering process.
#   The filtering dialog program (`builtin' is a internal
#   terminal dialog) has to provide the pass phrase on stdout.
SSLPassPhraseDialog builtin

#   Inter-Process Session Cache:
#   Configure the SSL Session Cache: First the mechanism
#   to use and second the expiring timeout (in seconds).
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)
SSLSessionCacheTimeout  300

#   Pseudo Random Number Generator (PRNG):
#   Configure one or more sources to seed the PRNG of the
#   SSL library. The seed data should be of good random quality.
#   WARNING! On some platforms /dev/random blocks if not enough entropy
#   is available. This means you then cannot use the /dev/random device
#   because it would lead to very long connection times (as long as
#   it requires to make more entropy available). But usually those
#   platforms additionally provide a /dev/urandom device which doesn't
#   block. So, if available, use this one instead. Read the mod_ssl User
#   Manual for more details.
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
#SSLRandomSeed startup file:/dev/random  512
#SSLRandomSeed connect file:/dev/random  512
#SSLRandomSeed connect file:/dev/urandom 512

#
# Use "SSLCryptoDevice" to enable any supported hardware
# accelerators. Use "openssl engine -v" to list supported
# engine names.  NOTE: If you enable an accelerator and the
# server does not start, consult the error logs and ensure
# your accelerator is functioning properly.
#
SSLCryptoDevice builtin
#SSLCryptoDevice ubsec

httpd.confの設定

sslモジュールをロードするように以下を追記します。

/etc/httpd/conf/httpd.conf

LoadModule ssl_module modules/mod_ssl.so

バーチャルホストの設定

当方の環境はバーチャルホストにしているので、バーチャルホストの設定ファイルに以下を追記

/etc/httpd/conf.d/vhosts/example.conf

<VirtualHost    *:443>
    ServerAdmin root@example.co.jp
    DocumentRoot /home/hoge/example.co.jp/html/
    ServerName example.co.jp
    ServerAlias www.example.co.jp
    ErrorLog /home/hoge/example.co.jp/logs/error_log
    CustomLog /home/hoge/example.co.jp/logs/access_log common
    
    SSLEngine   on
    SSLProtocol all -SSLv2 -SSLv3
    SSLCipherSuite  ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
    SSLCertificateFile  /etc/letsencrypt/live/example.co.jp/cert.pem
    SSLCertificateKeyFile   /etc/letsencrypt/live/example.co.jp/privkey.pem
    SSLCACertificateFile    /etc/letsencrypt/live/example.co.jp/fullchain.pem
    
    <Directory />
        Options Indexes
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

ここまで来たらhttpdを再起動してhttpsで接続できるはずです。

httpsを強制させる方法

httpd.confに以下を追記し、mod_rewriteモジュールをロードする。

LoadModule rewrite_module modules/mod_rewrite.so

バーチャルホストなもんで、以下のようにmod_rewritehttpsで接続するようにしてやります。

/etc/httpd/conf.d/vhosts/example.conf

<VirtualHost *:80>
    <!-- 中略  -->
    <ifModule mod_rewrite.c>
          RewriteEngine On
          RewriteLog "/var/log/httpd/rewrite_log"
          RewriteLogLevel 0

          RewriteCond %{SERVER_PORT} !^443$
          RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    </ifModule>
</VirtualHost>

簡単に説明すると、RewriteCondはrewriteする条件で、例の場合は443ポート以外で接続してきた場合、つまりhttps以外の場合ってことですね。

RewriteRuleはrewrite先を記述する。ちなみに末尾の[R, L]はオプションです。

力尽きたので、詳細はここを参考にしてください。。。

参考

User Guide — Certbot 0.10.0.dev0 documentation

Let’s Encrypt サーバー証明書の取得と自動更新設定メモ | あぱーブログ

Let's Encrypt編 - Apache 2.4系でHTTP/2対応サーバを構築してみるテスト。

http://jetstreamair.blogspot.jp/2015/12/ssllets-encryptcentos6.html

Redhat / CentOS 6.x users need python 2.7 - Server - Let's Encrypt Community Support

Redhat6.x + SCL 使う時に気をつけたい3つのポイント - AWS / PHP / Python ちょいメモ

apacheでhttpへのアクセスをhttpsへ自動リダイレクトする - Qiita

HTTPでアクセスした時、自動的にHTTPSにrewriteする

Apache : mod_rewriteリファレンス - dawgsdk.org

SSL証明書インストールに関するメモ | ぺんラボブログ

RSA鍵、証明書のファイルフォーマットについて - Qiita

opensslコマンドで証明書情報を確認したい。 | SSL・電子証明書ならGMOグローバルサイン

遭遇したエラー

Invalid command 'SSLEngine' 〜

$ service httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中: Syntax error on line 28 of /etc/httpd/conf.d/vhosts/example.conf:
Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration

原因

httpd.confにsslモジュールを読み込む設定をしていなかった。

対応

httpd.confに以下を追記

LoadModule ssl_module modules/mod_ssl.so

参考

mod_sslが有効にならない - myChuno::blog

SSLPassPhraseDialog: file '/usr/libexec/httpd-ssl-pass-dialog' does not exist

$ service httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中: Syntax error on line 19 of /etc/httpd/conf.d/ssl.conf:
SSLPassPhraseDialog: file '/usr/libexec/httpd-ssl-pass-dialog' does not exist
                                                           [失敗]

原因

/usr/libexec/httpd-ssl-pass-dialogがない。

参考にしたssl.confは

SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog

になってたんですが、これは「SSLパスフレーズの入力にhttpd-ssl-pass-dialogってスクリプトを使います」ってことだったらしい。

httpd-ssl-pass-dialogなんてスクリプトは作ってないし、そもそもLet's Encryptで生成したSSLのキーにパスワードは必要ないので、

SSLPassPhraseDialog builtin

で良い(ちなみに、SSLのキーにパスワードがかかっているときはダイアログが表示され、手入力が必要)。

対応

参考

Apacheの起動時にSSLのパスフレーズを省略する方法 - それマグで!

Apache2.4 + mod_ssl + SSL証明書 = ちょいつまづく? | 日記の間 | あかつきのお宿

httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

$ service httpd restart
httpd を停止中:                                            [失敗]
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

原因

httpd.confのServerNameディレクティブが未設定だったため

対応

httpd.confのServerName設定する。

# httpd.conf.defaultは変更前のhttpd.conf
$ diff /etc/httpd/conf/httpd.conf.default  /etc/httpd/conf/httpd.conf
276c278
< #ServerName www.example.com:80
---
> ServerName localhost:80

参考

Apache: 起動エラー – Could not reliably determine the server’s fully qualified domain name

Apacheのエラー:Could not reliably determine the server’s fully qualified domain name〜とメッセージが出たときの対応 - yummy-yummy

【CentOS6】Apache2.2インストール&設定

環境

インストール

Apache本体の他に以下パッケージもインストールしておく

  • httpd-devel: apxsなどの開発用ツールが含まれるパッケージ
  • httpd-tools: httpd の監視、統計、ログ分析、DoS の検出、および防衛のためのツールが含まれるパッケージ
  • httpd-manual: httpdのドキュメントページを含むパッケージ
$ yum -y install httpd httpd-devel httpd-tools  httpd-manual
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package httpd.x86_64 0:2.2.15-47.el6.centos.3 will be インストール
--> 依存性の処理をしています: apr-util-ldap のパッケージ: httpd-2.2.15-47.el6.centos.3.x86_64
--> 依存性の処理をしています: /etc/mime.types のパッケージ: httpd-2.2.15-47.el6.centos.3.x86_64
--> 依存性の処理をしています: libaprutil-1.so.0()(64bit) のパッケージ: httpd-2.2.15-47.el6.centos.3.x86_64
--> 依存性の処理をしています: libapr-1.so.0()(64bit) のパッケージ: httpd-2.2.15-47.el6.centos.3.x86_64
---> Package httpd-devel.x86_64 0:2.2.15-47.el6.centos.3 will be インストール
--> 依存性の処理をしています: apr-util-devel のパッケージ: httpd-devel-2.2.15-47.el6.centos.3.x86_64
--> 依存性の処理をしています: apr-devel のパッケージ: httpd-devel-2.2.15-47.el6.centos.3.x86_64
---> Package httpd-manual.noarch 0:2.2.15-47.el6.centos.3 will be インストール
---> Package httpd-tools.x86_64 0:2.2.15-47.el6.centos.3 will be インストール
--> トランザクションの確認を実行しています。
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be インストール
---> Package apr-devel.x86_64 0:1.3.9-5.el6_2 will be インストール
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be インストール
---> Package apr-util-devel.x86_64 0:1.3.9-3.el6_0.1 will be インストール
--> 依存性の処理をしています: openldap-devel のパッケージ: apr-util-devel-1.3.9-3.el6_0.1.x86_64
--> 依存性の処理をしています: expat-devel のパッケージ: apr-util-devel-1.3.9-3.el6_0.1.x86_64
--> 依存性の処理をしています: db4-devel のパッケージ: apr-util-devel-1.3.9-3.el6_0.1.x86_64
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be インストール
---> Package mailcap.noarch 0:2.1.31-2.el6 will be インストール
--> トランザクションの確認を実行しています。
---> Package db4-devel.x86_64 0:4.7.25-20.el6_7 will be インストール
--> 依存性の処理をしています: db4-cxx = 4.7.25-20.el6_7 のパッケージ: db4-devel-4.7.25-20.el6_7.x86_64
--> 依存性の処理をしています: libdb_cxx-4.7.so()(64bit) のパッケージ: db4-devel-4.7.25-20.el6_7.x86_64
---> Package expat-devel.x86_64 0:2.0.1-11.el6_2 will be インストール
---> Package openldap-devel.x86_64 0:2.4.40-7.el6_7 will be インストール
--> 依存性の処理をしています: cyrus-sasl-devel >= 2.1 のパッケージ: openldap-devel-2.4.40-7.el6_7.x86_64
--> トランザクションの確認を実行しています。
---> Package cyrus-sasl-devel.x86_64 0:2.1.23-15.el6_6.2 will be インストール
---> Package db4-cxx.x86_64 0:4.7.25-20.el6_7 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================================================================================
 パッケージ                                       アーキテクチャ                         バージョン                                             リポジトリー                             容量
==============================================================================================================================================================================================
インストールしています:
 httpd                                            x86_64                                 2.2.15-47.el6.centos.3                                 updates                                 831 k
 httpd-devel                                      x86_64                                 2.2.15-47.el6.centos.3                                 updates                                 155 k
 httpd-manual                                     noarch                                 2.2.15-47.el6.centos.3                                 updates                                 788 k
 httpd-tools                                      x86_64                                 2.2.15-47.el6.centos.3                                 updates                                  77 k
依存性関連でのインストールをします。:
 apr                                              x86_64                                 1.3.9-5.el6_2                                          base                                    123 k
 apr-devel                                        x86_64                                 1.3.9-5.el6_2                                          base                                    176 k
 apr-util                                         x86_64                                 1.3.9-3.el6_0.1                                        base                                     87 k
 apr-util-devel                                   x86_64                                 1.3.9-3.el6_0.1                                        base                                     69 k
 apr-util-ldap                                    x86_64                                 1.3.9-3.el6_0.1                                        base                                     15 k
 cyrus-sasl-devel                                 x86_64                                 2.1.23-15.el6_6.2                                      base                                    303 k
 db4-cxx                                          x86_64                                 4.7.25-20.el6_7                                        updates                                 588 k
 db4-devel                                        x86_64                                 4.7.25-20.el6_7                                        updates                                 6.6 M
 expat-devel                                      x86_64                                 2.0.1-11.el6_2                                         base                                    120 k
 mailcap                                          noarch                                 2.1.31-2.el6                                           base                                     27 k
 openldap-devel                                   x86_64                                 2.4.40-7.el6_7                                         updates                                 1.1 M

トランザクションの要約
==============================================================================================================================================================================================
インストール        15 パッケージ

総ダウンロード容量: 11 M
インストール済み容量: 41 M
パッケージをダウンロードしています:
(1/15): apr-1.3.9-5.el6_2.x86_64.rpm                                                                                                                                   | 123 kB     00:00     
(2/15): apr-devel-1.3.9-5.el6_2.x86_64.rpm                                                                                                                             | 176 kB     00:00     
(3/15): apr-util-1.3.9-3.el6_0.1.x86_64.rpm                                                                                                                            |  87 kB     00:00     
(4/15): apr-util-devel-1.3.9-3.el6_0.1.x86_64.rpm                                                                                                                      |  69 kB     00:00     
(5/15): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm                                                                                                                       |  15 kB     00:00     
(6/15): cyrus-sasl-devel-2.1.23-15.el6_6.2.x86_64.rpm                                                                                                                  | 303 kB     00:00     
(7/15): db4-cxx-4.7.25-20.el6_7.x86_64.rpm                                                                                                                             | 588 kB     00:00     
(8/15): db4-devel-4.7.25-20.el6_7.x86_64.rpm                                                                                                                           | 6.6 MB     00:02     
(9/15): expat-devel-2.0.1-11.el6_2.x86_64.rpm                                                                                                                          | 120 kB     00:00     
(10/15): httpd-2.2.15-47.el6.centos.3.x86_64.rpm                                                                                                                       | 831 kB     00:00     
(11/15): httpd-devel-2.2.15-47.el6.centos.3.x86_64.rpm                                                                                                                 | 155 kB     00:00     
(12/15): httpd-manual-2.2.15-47.el6.centos.3.noarch.rpm                                                                                                                | 788 kB     00:00     
(13/15): httpd-tools-2.2.15-47.el6.centos.3.x86_64.rpm                                                                                                                 |  77 kB     00:00     
(14/15): mailcap-2.1.31-2.el6.noarch.rpm                                                                                                                               |  27 kB     00:00     
(15/15): openldap-devel-2.4.40-7.el6_7.x86_64.rpm                                                                                                                      | 1.1 MB     00:00     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                                                          1.1 MB/s |  11 MB     00:10     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : apr-1.3.9-5.el6_2.x86_64                                                                                                                                     1/15 
  インストールしています  : apr-util-1.3.9-3.el6_0.1.x86_64                                                                                                                              2/15 
  インストールしています  : apr-devel-1.3.9-5.el6_2.x86_64                                                                                                                               3/15 
  インストールしています  : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                                                                                                                         4/15 
  インストールしています  : httpd-tools-2.2.15-47.el6.centos.3.x86_64                                                                                                                    5/15 
  インストールしています  : mailcap-2.1.31-2.el6.noarch                                                                                                                                  6/15 
  インストールしています  : httpd-2.2.15-47.el6.centos.3.x86_64                                                                                                                          7/15 
  インストールしています  : db4-cxx-4.7.25-20.el6_7.x86_64                                                                                                                               8/15 
  インストールしています  : db4-devel-4.7.25-20.el6_7.x86_64                                                                                                                             9/15 
  インストールしています  : expat-devel-2.0.1-11.el6_2.x86_64                                                                                                                           10/15 
  インストールしています  : cyrus-sasl-devel-2.1.23-15.el6_6.2.x86_64                                                                                                                   11/15 
  インストールしています  : openldap-devel-2.4.40-7.el6_7.x86_64                                                                                                                        12/15 
  インストールしています  : apr-util-devel-1.3.9-3.el6_0.1.x86_64                                                                                                                       13/15 
  インストールしています  : httpd-devel-2.2.15-47.el6.centos.3.x86_64                                                                                                                   14/15 
  インストールしています  : httpd-manual-2.2.15-47.el6.centos.3.noarch                                                                                                                  15/15 
  Verifying               : httpd-devel-2.2.15-47.el6.centos.3.x86_64                                                                                                                    1/15 
  Verifying               : httpd-manual-2.2.15-47.el6.centos.3.noarch                                                                                                                   2/15 
  Verifying               : apr-devel-1.3.9-5.el6_2.x86_64                                                                                                                               3/15 
  Verifying               : cyrus-sasl-devel-2.1.23-15.el6_6.2.x86_64                                                                                                                    4/15 
  Verifying               : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                                                                                                                         5/15 
  Verifying               : openldap-devel-2.4.40-7.el6_7.x86_64                                                                                                                         6/15 
  Verifying               : apr-1.3.9-5.el6_2.x86_64                                                                                                                                     7/15 
  Verifying               : apr-util-devel-1.3.9-3.el6_0.1.x86_64                                                                                                                        8/15 
  Verifying               : httpd-tools-2.2.15-47.el6.centos.3.x86_64                                                                                                                    9/15 
  Verifying               : db4-devel-4.7.25-20.el6_7.x86_64                                                                                                                            10/15 
  Verifying               : apr-util-1.3.9-3.el6_0.1.x86_64                                                                                                                             11/15 
  Verifying               : expat-devel-2.0.1-11.el6_2.x86_64                                                                                                                           12/15 
  Verifying               : db4-cxx-4.7.25-20.el6_7.x86_64                                                                                                                              13/15 
  Verifying               : mailcap-2.1.31-2.el6.noarch                                                                                                                                 14/15 
  Verifying               : httpd-2.2.15-47.el6.centos.3.x86_64                                                                                                                         15/15 

インストール:
  httpd.x86_64 0:2.2.15-47.el6.centos.3     httpd-devel.x86_64 0:2.2.15-47.el6.centos.3     httpd-manual.noarch 0:2.2.15-47.el6.centos.3     httpd-tools.x86_64 0:2.2.15-47.el6.centos.3    

依存性関連をインストールしました:
  apr.x86_64 0:1.3.9-5.el6_2                   apr-devel.x86_64 0:1.3.9-5.el6_2                  apr-util.x86_64 0:1.3.9-3.el6_0.1            apr-util-devel.x86_64 0:1.3.9-3.el6_0.1      
  apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1       cyrus-sasl-devel.x86_64 0:2.1.23-15.el6_6.2       db4-cxx.x86_64 0:4.7.25-20.el6_7             db4-devel.x86_64 0:4.7.25-20.el6_7           
  expat-devel.x86_64 0:2.0.1-11.el6_2          mailcap.noarch 0:2.1.31-2.el6                     openldap-devel.x86_64 0:2.4.40-7.el6_7      

完了しました!

ファイアウォールの設定

http通信に利用される80番ポートを開けておきます。

$ iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

iptables再起動

$ service iptables restart
iptables: チェインをポリシー ACCEPT へ設定中filter         [  OK  ]
iptables: ファイアウォールルールを消去中:                  [  OK  ]
iptables: モジュールを取り外し中:                          [  OK  ]
iptables: ファイアウォールルールを適用中:                  [  OK  ]

確認

$ iptables -L -n | grep 80
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:80

ポートマッピング

自分のサーバのネットワークはブロードバンドルータをかませているので、ポートマッピング(ポートフォワーディング)を設定します。

これは利用しているルータによって設定方法が異なると思うので割愛します。

Apacheの設定

バーチャルホスト

今回はネームベースでバーチャルホストを設定します。

まずはhttpd.confから

/etc/httpd/conf/httpd.conf

#NameVirtualHost *:80

コメントアウトされている箇所を

NameVirtualHost *:80

コメントアウトを外します。

次にバーチャルホストの設定。

バーチャルホストの設定はhttpd.confに書いてもいいのですが、数が増えてくると管理しにくいので、/etc/httpd/conf.d/vhosts/ 配下にバーチャルホストごとに設定ファイルを作る(1バーチャルホスト=1ファイル)という運用にします。

というわけで、今回はvhostsディレクトリ配下にバーチャルホスト毎の設定ファイルを置くことにします。

/etc/httpd/conf.d/httpd-vhosts.conf

#
# Include virtual host based config file.
#
Include conf.d/vhosts/*.conf # vhostsディレクトリ配下の〜.confファイルを読み込むようにする

バーチャルホストごとに設定ファイルを作成

/etc/httpd/conf.d/vhosts/example.conf

#
# example.co.jp
#
<VirtualHost *:80>
    ServerAdmin root@example
    DocumentRoot /home/apache/example/html/
    ServerName example.co.jp
    ServerAlias www.example.co.jp
    ErrorLog /home/apache/example/logs/error_log
    CustomLog /home/apache/example/logs/access_log common

    <Directory />
        Options Indexes
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

アクセス

上記の設定の場合、http://example.co.jp もしくは http://www.example.co.jp でアクセスできるはずです。

f:id:mktktmr:20160301035915p:plain

上記のテストページが出ればOKです。

ちなみに、インストール時にhttpd-manualも入れておけば、http://example.co.jp/manual にアクセスした時に、Apacheのマニュアルに飛べるはずです。

f:id:mktktmr:20160309045526p:plain

自動起動設定

OSを再起動した時もサーバが自動的に立ち上がるように、設定を変更します。

# 確認
chkconfig | grep httpd
httpd           0:off  1:off  2:off  3:off  4:off  5:off  6:off # デフォルトだとoffなので...
# chkconfig を on に
$ chkconfig httpd on
# 確認
$ chkconfig | grep httpd
httpd           0:off  1:off  2:on   3:on   4:on   5:on   6:off

参考

Apache HTTP サーバ バージョン 2.2 ドキュメント - Apache HTTP サーバ バージョン 2.2

Apache 2.2.xでネームベースのVirtual Hostの設定 - Qiita

apache2.2 バーチャルホストの設定 前編

Apache httpd tools freecode日本語情報ページ - OSDN

Chapter 17. Web Servers

【Python】URLエンコードされたテキストファイルをデコードしてファイル出力

URLエンコードされた文字列が吐かれたログファイルをデコードすることがあったので、お勉強がてら作ってみた。

環境

Python 2.7.10

ソース

f_cnv.py

#!/usr/bin/python
# -*- coding: utf-8 -*-

# 文字コードの指定:http://yono.cc/python/python_basics/japanese.html
# コメント:http://python301.blog123.fc2.com/blog-entry-9.html

import sys
import urllib

# 命名規約:http://nekowarau.seesaa.net/article/426647551.html
def url_decode(input_path, output_path):
    
    # if文:http://www.pythonweb.jp/tutorial/if/index4.html
    # 論理演算子:http://www.pythonweb.jp/tutorial/if/index6.html
    if input_path == "" and output_path =="":
        sys.exit ("error: The number of parameters has to be 2" + "\n" + "info: First param is input file path, second param is output file path")

    print "input file is " + input_path + ", " + "output file is " + output_path

    # 数値=>文字列:http://www.pythonweb.jp/tutorial/string/index9.html
    # インデックス付きfor:http://www.gesource.jp/programming/python/code/0022.html
    """
    strParam = ""
    for i, e in enumerate(param):
        strParam = strParam + " param[" + str(i) + "]" + "=" + e

    print "info: param is" + strParam
    """

    # ファイル入力:http://www.yukun.info/blog/2008/06/python-file.html#readlines_8211_1
    rf = open(input_path)
    lines = rf.readlines() 
    rf.close()

    # ファイル出力:http://www.mwsoft.jp/programming/python/file.html
    wf  = open(output_path, "w")

    for line in lines:
        # urlエンコード・デコード:http://python.g.hatena.ne.jp/mhrs/20060609/p1
        decodedLine = urllib.unquote_plus(line);
        wf.write(decodedLine)
    print

    wf.close()

# メイン関数的な:http://qiita.com/shunsuke227ono/items/a043bfa9998e7033de3a
if __name__ == "__main__":
    
    # コマンドライン引数:http://www.python-izm.com/contents/basis/command_line_arguments.shtml
    param = sys.argv

    # 配列のサイズ:http://www.pythonweb.jp/tutorial/list/index5.html
    if len(param) != 3:
        # 終了メソッド:http://d.hatena.ne.jp/kakurasan/20110512/p1
        sys.exit ("error: The number of parameters has to be 2" + "\n" + "info: First param is input file path, second param is output file path")
    
    url_decode(param[1], param[2])

使い方

第一引数に入力ファイル、第二引数に出力ファイルのパスを渡します。

スクリプトとして実行

例)encode.txtをデコードしてdecode.txtとして出力

$ ./f_env.py /home/hoge/Documents/encode.txt /home/hoge/Documents/decode.txt

モジュールとして実行

例)上記と同じ処理を対話型シェルで実行

$ python
>>> import f_env
>>> f_cnv.url_decode("/home/hoge/Documents/encode.txt", "/home/hoge/Documents/decode.txt")

.pycファイル

上記のモジュールとして実行で呼び出すと「f_env.pyc」というファイルが作られていた。

こいつはなんぞと思いググってみた。

.pycファイルを作成させない方法メモ - かせきのうさぎさん

Python で書かれたモジュールを import すると自動的に .pycファイルが作成される。このファイルはコンパイルして得られたバイトコードを保存したものだ。つまり一種のキャッシュである。モジュールは他のファイルからも import される可能性が高いので、こうしておけばコンパイルする時間を節約できる。

ということらしい。

【CentOS6】java8 + Tomcat7をインストール

今回はyumを利用します。

yumを利用するとパスをごにょごにょしたり、起動スクリプト自作しなくてよかったりメリットあるので利用します。

yumに頼った所為でハマったのですが。。。

自分の手で色々やってインストールするなら↓が詳しくて良いかも。

LinuxサーバへのTomcat 7導入 (Tomcatインストール)

環境

  • サーバOS: CentOS6.7
  • webサーバ: Apache2.2

手順

javaのインストール

java8関連のパッケージはベースリポジトリにあるのでyumでインストール。

$ yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: centosv4.centos.org
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.71-1.b15.el6_7 will be インストール
--> 依存性の処理をしています: java-1.8.0-openjdk-headless = 1:1.8.0.71-1.b15.el6_7 のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: xorg-x11-fonts-Type1 のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libjvm.so(SUNWprivate_1.1)(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libjava.so(SUNWprivate_1.1)(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libasound.so.2(ALSA_0.9.0rc4)(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libasound.so.2(ALSA_0.9)(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libjvm.so()(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libjava.so()(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libgif.so.4()(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libawt.so()(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libasound.so.2()(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: libXtst.so.6()(64bit) のパッケージ: 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.71-1.b15.el6_7 will be インストール
--> トランザクションの確認を実行しています。
---> Package alsa-lib.x86_64 0:1.0.22-3.el6 will be インストール
---> Package giflib.x86_64 0:4.1.6-3.1.el6 will be インストール
--> 依存性の処理をしています: libSM.so.6()(64bit) のパッケージ: giflib-4.1.6-3.1.el6.x86_64
--> 依存性の処理をしています: libICE.so.6()(64bit) のパッケージ: giflib-4.1.6-3.1.el6.x86_64
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.71-1.b15.el6_7 will be インストール
--> 依存性の処理をしています: tzdata-java >= 2014f-1 のパッケージ: 1:java-1.8.0-openjdk-headless-1.8.0.71-1.b15.el6_7.x86_64
--> 依存性の処理をしています: jpackage-utils のパッケージ: 1:java-1.8.0-openjdk-headless-1.8.0.71-1.b15.el6_7.x86_64
---> Package libXtst.x86_64 0:1.2.2-2.1.el6 will be インストール
---> Package xorg-x11-fonts-Type1.noarch 0:7.2-11.el6 will be インストール
--> 依存性の処理をしています: ttmkfdir のパッケージ: xorg-x11-fonts-Type1-7.2-11.el6.noarch
--> 依存性の処理をしています: ttmkfdir のパッケージ: xorg-x11-fonts-Type1-7.2-11.el6.noarch
--> 依存性の処理をしています: mkfontdir のパッケージ: xorg-x11-fonts-Type1-7.2-11.el6.noarch
--> 依存性の処理をしています: mkfontdir のパッケージ: xorg-x11-fonts-Type1-7.2-11.el6.noarch
--> トランザクションの確認を実行しています。
---> Package jpackage-utils.noarch 0:1.7.5-3.14.el6 will be インストール
---> Package libICE.x86_64 0:1.0.6-1.el6 will be インストール
---> Package libSM.x86_64 0:1.2.1-2.el6 will be インストール
---> Package ttmkfdir.x86_64 0:3.0.9-32.1.el6 will be インストール
---> Package tzdata-java.noarch 0:2016a-2.el6 will be インストール
---> Package xorg-x11-font-utils.x86_64 1:7.2-11.el6 will be インストール
--> 依存性の処理をしています: libfontenc.so.1()(64bit) のパッケージ: 1:xorg-x11-font-utils-7.2-11.el6.x86_64
--> 依存性の処理をしています: libXfont.so.1()(64bit) のパッケージ: 1:xorg-x11-font-utils-7.2-11.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package libXfont.x86_64 0:1.4.5-5.el6_7 will be インストール
---> Package libfontenc.x86_64 0:1.0.5-2.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

=======================================================================================================================
 パッケージ                             アーキテクチャ    バージョン                          リポジトリー        容量
=======================================================================================================================
インストールしています:
 java-1.8.0-openjdk                     x86_64            1:1.8.0.71-1.b15.el6_7              updates            190 k
 java-1.8.0-openjdk-devel               x86_64            1:1.8.0.71-1.b15.el6_7              updates             10 M
依存性関連でのインストールをします。:
 alsa-lib                               x86_64            1.0.22-3.el6                        base               370 k
 giflib                                 x86_64            4.1.6-3.1.el6                       base                37 k
 java-1.8.0-openjdk-headless            x86_64            1:1.8.0.71-1.b15.el6_7              updates             32 M
 jpackage-utils                         noarch            1.7.5-3.14.el6                      base                60 k
 libICE                                 x86_64            1.0.6-1.el6                         base                53 k
 libSM                                  x86_64            1.2.1-2.el6                         base                37 k
 libXfont                               x86_64            1.4.5-5.el6_7                       updates            137 k
 libXtst                                x86_64            1.2.2-2.1.el6                       base                19 k
 libfontenc                             x86_64            1.0.5-2.el6                         base                24 k
 ttmkfdir                               x86_64            3.0.9-32.1.el6                      base                43 k
 tzdata-java                            noarch            2016a-2.el6                         updates            177 k
 xorg-x11-font-utils                    x86_64            1:7.2-11.el6                        base                75 k
 xorg-x11-fonts-Type1                   noarch            7.2-11.el6                          base               520 k

トランザクションの要約
=======================================================================================================================
インストール        15 パッケージ

総ダウンロード容量: 43 M
インストール済み容量: 146 M
パッケージをダウンロードしています:
(1/15): alsa-lib-1.0.22-3.el6.x86_64.rpm                                                        | 370 kB     00:00     
(2/15): giflib-4.1.6-3.1.el6.x86_64.rpm                                                         |  37 kB     00:00     
(3/15): java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64.rpm                                      | 190 kB     00:01     
(4/15): java-1.8.0-openjdk-devel-1.8.0.71-1.b15.el6_7.x86_64.rpm                                |  10 MB     01:27     
(5/15): java-1.8.0-openjdk-headless-1.8.0.71-1.b15.el6_7.x86_64.rpm                             |  32 MB     03:50     
(6/15): jpackage-utils-1.7.5-3.14.el6.noarch.rpm                                                |  60 kB     00:00     
(7/15): libICE-1.0.6-1.el6.x86_64.rpm                                                           |  53 kB     00:00     
(8/15): libSM-1.2.1-2.el6.x86_64.rpm                                                            |  37 kB     00:00     
(9/15): libXfont-1.4.5-5.el6_7.x86_64.rpm                                                       | 137 kB     00:01     
(10/15): libXtst-1.2.2-2.1.el6.x86_64.rpm                                                       |  19 kB     00:00     
(11/15): libfontenc-1.0.5-2.el6.x86_64.rpm                                                      |  24 kB     00:00     
(12/15): ttmkfdir-3.0.9-32.1.el6.x86_64.rpm                                                     |  43 kB     00:00     
(13/15): tzdata-java-2016a-2.el6.noarch.rpm                                                     | 177 kB     00:01     
(14/15): xorg-x11-font-utils-7.2-11.el6.x86_64.rpm                                              |  75 kB     00:00     
(15/15): xorg-x11-fonts-Type1-7.2-11.el6.noarch.rpm                                             | 520 kB     00:00     
-----------------------------------------------------------------------------------------------------------------------
合計                                                                                   136 kB/s |  43 MB     05:27     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : libfontenc-1.0.5-2.el6.x86_64                                                         1/15 
  インストールしています  : libICE-1.0.6-1.el6.x86_64                                                             2/15 
  インストールしています  : libSM-1.2.1-2.el6.x86_64                                                              3/15 
  インストールしています  : giflib-4.1.6-3.1.el6.x86_64                                                           4/15 
  インストールしています  : libXfont-1.4.5-5.el6_7.x86_64                                                         5/15 
  インストールしています  : 1:xorg-x11-font-utils-7.2-11.el6.x86_64                                               6/15 
  インストールしています  : libXtst-1.2.2-2.1.el6.x86_64                                                          7/15 
  インストールしています  : alsa-lib-1.0.22-3.el6.x86_64                                                          8/15 
  インストールしています  : tzdata-java-2016a-2.el6.noarch                                                        9/15 
  インストールしています  : jpackage-utils-1.7.5-3.14.el6.noarch                                                 10/15 
  インストールしています  : ttmkfdir-3.0.9-32.1.el6.x86_64                                                       11/15 
  インストールしています  : xorg-x11-fonts-Type1-7.2-11.el6.noarch                                               12/15 
  インストールしています  : 1:java-1.8.0-openjdk-headless-1.8.0.71-1.b15.el6_7.x86_64                            13/15 
  インストールしています  : 1:java-1.8.0-openjdk-devel-1.8.0.71-1.b15.el6_7.x86_64                               14/15 
  インストールしています  : 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64                                     15/15 
  Verifying               : ttmkfdir-3.0.9-32.1.el6.x86_64                                                        1/15 
  Verifying               : libXfont-1.4.5-5.el6_7.x86_64                                                         2/15 
  Verifying               : jpackage-utils-1.7.5-3.14.el6.noarch                                                  3/15 
  Verifying               : libICE-1.0.6-1.el6.x86_64                                                             4/15 
  Verifying               : libfontenc-1.0.5-2.el6.x86_64                                                         5/15 
  Verifying               : tzdata-java-2016a-2.el6.noarch                                                        6/15 
  Verifying               : alsa-lib-1.0.22-3.el6.x86_64                                                          7/15 
  Verifying               : 1:xorg-x11-font-utils-7.2-11.el6.x86_64                                               8/15 
  Verifying               : 1:java-1.8.0-openjdk-devel-1.8.0.71-1.b15.el6_7.x86_64                                9/15 
  Verifying               : libSM-1.2.1-2.el6.x86_64                                                             10/15 
  Verifying               : libXtst-1.2.2-2.1.el6.x86_64                                                         11/15 
  Verifying               : xorg-x11-fonts-Type1-7.2-11.el6.noarch                                               12/15 
  Verifying               : 1:java-1.8.0-openjdk-1.8.0.71-1.b15.el6_7.x86_64                                     13/15 
  Verifying               : 1:java-1.8.0-openjdk-headless-1.8.0.71-1.b15.el6_7.x86_64                            14/15 
  Verifying               : giflib-4.1.6-3.1.el6.x86_64                                                          15/15 

インストール:
  java-1.8.0-openjdk.x86_64 1:1.8.0.71-1.b15.el6_7        java-1.8.0-openjdk-devel.x86_64 1:1.8.0.71-1.b15.el6_7       

依存性関連をインストールしました:
  alsa-lib.x86_64 0:1.0.22-3.el6                                      giflib.x86_64 0:4.1.6-3.1.el6                    
  java-1.8.0-openjdk-headless.x86_64 1:1.8.0.71-1.b15.el6_7           jpackage-utils.noarch 0:1.7.5-3.14.el6           
  libICE.x86_64 0:1.0.6-1.el6                                         libSM.x86_64 0:1.2.1-2.el6                       
  libXfont.x86_64 0:1.4.5-5.el6_7                                     libXtst.x86_64 0:1.2.2-2.1.el6                   
  libfontenc.x86_64 0:1.0.5-2.el6                                     ttmkfdir.x86_64 0:3.0.9-32.1.el6                 
  tzdata-java.noarch 0:2016a-2.el6                                    xorg-x11-font-utils.x86_64 1:7.2-11.el6          
  xorg-x11-fonts-Type1.noarch 0:7.2-11.el6                           

完了しました!

確認

$ java -version
openjdk version "1.8.0_71"
OpenJDK Runtime Environment (build 1.8.0_71-b15)
OpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode)

Tomcatのインストール

残念ながらCentOS6のリポジトリにTomcat7はないので(バージョン6はある)、サードパーティリポジトリから入手する。

# ないんです><
$ yum search tomcat7
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: centosx4.centos.org
警告: 一致するものが見つかりません: tomcat7
見つかりませんでした

jpackageリポジトリの取得

Tomcat7はjava関連のパッケージを提供してるjpackageリポジトリから取得することにします。

:: JPackage Project | Home ::

rpm -Uvh http://mirrors.dotsrc.org/jpackage/6.0/generic/free/RPMS/jpackage-release-6-3.jpp6.noarch.rpm
http://mirrors.dotsrc.org/jpackage/6.0/generic/free/RPMS/jpackage-release-6-3.jpp6.noarch.rpm を取得中
エラー: 依存性の欠如:
    yum-priorities は jpackage-release-6-3.jpp6.noarch に必要とされています

yum-prioritiesを入れないとダメみたいです。

$ yum install -y yum-priorities
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: centosv4.centos.org
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package yum-plugin-priorities.noarch 0:1.1.30-30.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

============================================================================================================================
 パッケージ                             アーキテクチャ          バージョン                      リポジトリー           容量
============================================================================================================================
インストールしています:
 yum-plugin-priorities                  noarch                  1.1.30-30.el6                   base                   25 k

トランザクションの要約
============================================================================================================================
インストール         1 パッケージ

総ダウンロード容量: 25 k
インストール済み容量: 28 k
パッケージをダウンロードしています:
yum-plugin-priorities-1.1.30-30.el6.noarch.rpm                                                       |  25 kB     00:00     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : yum-plugin-priorities-1.1.30-30.el6.noarch                                                  1/1 
  Verifying               : yum-plugin-priorities-1.1.30-30.el6.noarch                                                  1/1 

インストール:
  yum-plugin-priorities.noarch 0:1.1.30-30.el6                                                                              

完了しました!

気を取り直してリポジトリを取得。

$ rpm -Uvh http://mirrors.dotsrc.org/jpackage/6.0/generic/free/RPMS/jpackage-release-6-3.jpp6.noarch.rpm
http://mirrors.dotsrc.org/jpackage/6.0/generic/free/RPMS/jpackage-release-6-3.jpp6.noarch.rpm を取得中
準備中...                ########################################### [100%]
   1:jpackage-release       ########################################### [100%]

確認

$ cat /etc/yum.repos.d/jpackage.repo
[jpackage]
name=JPackage 6 generic
mirrorlist=http://www.jpackage.org/mirrorlist.php?dist=generic&type=free&release=6.0
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-jpackage
priority=10

インストール

念のため、tomcat7がリポジトリにあるか確認

$ yum search tomcat7
読み込んだプラグイン:fastestmirror, priorities
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.iij.ad.jp
 * jpackage: mirrors.dotsrc.org
 * rpmforge: ftp.kddilabs.jp
 * updates: centosd6.centos.org
jpackage                                                                                             | 1.9 kB     00:00     
jpackage/primary_db                                                                                  | 1.7 MB     00:06     
238 packages excluded due to repository priority protections
=================================================== N/S Matched: tomcat7 ===================================================
tomcat7.noarch : Apache Servlet/JSP Engine, RI for Servlet 3.0/JSP 2.2 API
tomcat7-admin-webapps.noarch : The host-manager and manager web applications for Apache Tomcat
tomcat7-docs-webapp.noarch : The docs web application for Apache Tomcat
tomcat7-el-2.2-api.noarch : Expression Language v2.2 API
tomcat7-javadoc.noarch : Javadoc generated documentation for Apache Tomcat
tomcat7-jsp-2.2-api.noarch : Apache Tomcat JSP API implementation classes
tomcat7-lib.noarch : Libraries needed to run the Tomcat Web container
tomcat7-servlet-3.0-api.noarch : Apache Tomcat Servlet API implementation classes
tomcat7-webapps.noarch : The ROOT and examples web applications for Apache Tomcat

  Name and summary matches only, use "search all" for everything.

大丈夫ですね!

前置きが長くなりましたが、ようやくtomcatをインストール。

# せっかくなんで管理ページも入れておく
$ yum -y install tomcat7-webapps tomcat7-admin-webapps
読み込んだプラグイン:fastestmirror, priorities
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.iij.ad.jp
 * jpackage: mirror.ibcp.fr
 * rpmforge: ftp.kddilabs.jp
 * updates: centosd6.centos.org
238 packages excluded due to repository priority protections
依存性の解決をしています
--> トランザクションの確認を実行しています。
#〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜(中略)〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
トランザクションの要約
============================================================================================================================
インストール        41 パッケージ

合計容量: 35 M
インストール済み容量: 91 M
パッケージをダウンロードしています:


パッケージ tomcat7-7.0.54-2.jpp6.noarch.rpm は署名されていません

。。。と思ったら、署名されていないとか言われてインストールできません。

--nogpgcheckオプションをつけて再実行。

$ yum install -y --nogpgcheck tomcat7-webapps tomcat7-admin-webapps
読み込んだプラグイン:fastestmirror, priorities
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.iij.ad.jp
 * jpackage: mirrors.dotsrc.org
 * rpmforge: ftp.kddilabs.jp
 * updates: centosv4.centos.org
238 packages excluded due to repository priority protections
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package tomcat7-admin-webapps.noarch 0:7.0.54-2.jpp6 will be インストール
--> 依存性の処理をしています: tomcat7 = 7.0.54-2.jpp6 のパッケージ: tomcat7-admin-webapps-7.0.54-2.jpp6.noarch
---> Package tomcat7-webapps.noarch 0:7.0.54-2.jpp6 will be インストール
--> 依存性の処理をしています: jakarta-taglibs-standard >= 1.1 のパッケージ: tomcat7-webapps-7.0.54-2.jpp6.noarch
--> トランザクションの確認を実行しています。
---> Package apache-taglibs-standard.noarch 0:1.1.2-8.jpp6 will be インストール
--> 依存性の処理をしています: xalan-j2 >= 2.6.0 のパッケージ: apache-taglibs-standard-1.1.2-8.jpp6.noarch
--> 依存性の処理をしています: jsp_2_1_api のパッケージ: apache-taglibs-standard-1.1.2-8.jpp6.noarch
--> 依存性の処理をしています: servlet_2_5_api のパッケージ: apache-taglibs-standard-1.1.2-8.jpp6.noarch
---> Package tomcat7.noarch 0:7.0.54-2.jpp6 will be インストール
--> 依存性の処理をしています: tomcat7-lib = 7.0.54-2.jpp6 のパッケージ: tomcat7-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: apache-commons-daemon のパッケージ: tomcat7-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: /lib/lsb/init-functions のパッケージ: tomcat7-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: apache-commons-logging のパッケージ: tomcat7-7.0.54-2.jpp6.noarch
--> トランザクションの確認を実行しています。
---> Package apache-commons-daemon.noarch 1:1.0.15-1.jpp6 will be インストール
---> Package apache-commons-logging.noarch 0:1.1.3-2.jpp6 will be インストール
---> Package redhat-lsb-core.x86_64 0:4.0-7.el6.centos will be インストール
--> 依存性の処理をしています: perl-Test-Simple のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: perl-Test-Harness のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: perl-ExtUtils-MakeMaker のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: perl-CGI のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: /usr/bin/time のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: /usr/bin/pax のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: /usr/bin/patch のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: /usr/bin/msgfmt のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: /usr/bin/man のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: /usr/bin/bc のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: /usr/bin/batch のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: /usr/bin/at のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
--> 依存性の処理をしています: /bin/gettext のパッケージ: redhat-lsb-core-4.0-7.el6.centos.x86_64
---> Package tomcat6-jsp-2.1-api.noarch 0:6.0.33-2.jpp6 will be インストール
---> Package tomcat6-servlet-2.5-api.noarch 0:6.0.33-2.jpp6 will be インストール
---> Package tomcat7-lib.noarch 0:7.0.54-2.jpp6 will be インストール
--> 依存性の処理をしています: tomcat7-servlet-3.0-api = 7.0.54-2.jpp6 のパッケージ: tomcat7-lib-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: tomcat7-jsp-2.2-api = 7.0.54-2.jpp6 のパッケージ: tomcat7-lib-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: tomcat7-el-2.2-api = 7.0.54-2.jpp6 のパッケージ: tomcat7-lib-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: /usr/share/java/ecj3.jar のパッケージ: tomcat7-lib-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: apache-commons-dbcp-tomcat5 のパッケージ: tomcat7-lib-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: apache-commons-pool-tomcat5 のパッケージ: tomcat7-lib-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: ecj3 のパッケージ: tomcat7-lib-7.0.54-2.jpp6.noarch
--> 依存性の処理をしています: apache-commons-collections-tomcat5 のパッケージ: tomcat7-lib-7.0.54-2.jpp6.noarch
---> Package xalan-j2.noarch 0:2.7.1-8.jbossorg_1.jpp6 will be インストール
--> 依存性の処理をしています: jaxp_parser_impl のパッケージ: xalan-j2-2.7.1-8.jbossorg_1.jpp6.noarch
--> トランザクションの確認を実行しています。
---> Package apache-commons-collections-tomcat5.noarch 0:3.2.1-6.jpp6 will be インストール
---> Package apache-commons-dbcp-tomcat5.noarch 0:1.3.0-0.r830852.4.jpp6 will be インストール
---> Package apache-commons-pool-tomcat5.noarch 0:1.5.7-1.jpp6 will be インストール
---> Package at.x86_64 0:3.1.10-48.el6 will be インストール
---> Package bc.x86_64 0:1.06.95-1.el6 will be インストール
---> Package ecj3.noarch 1:3.7-1.jpp6 will be インストール
---> Package gettext.x86_64 0:0.17-18.el6 will be インストール
--> 依存性の処理をしています: cvs のパッケージ: gettext-0.17-18.el6.x86_64
---> Package java-1.5.0-gcj.x86_64 0:1.5.0.0-29.1.el6 will be インストール
--> 依存性の処理をしています: libgcj >= 4.1.2-5 のパッケージ: java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
--> 依存性の処理をしています: sinjdoc のパッケージ: java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
--> 依存性の処理をしています: /usr/lib64/security/classpath.security のパッケージ: java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
--> 依存性の処理をしています: /usr/bin/gij のパッケージ: java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
--> 依存性の処理をしています: /usr/bin/gij のパッケージ: java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
--> 依存性の処理をしています: /usr/bin/gcj-dbtool のパッケージ: java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
--> 依存性の処理をしています: /usr/bin/gcj-dbtool のパッケージ: java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
---> Package man.x86_64 0:1.6f-32.el6 will be インストール
--> 依存性の処理をしています: lzma のパッケージ: man-1.6f-32.el6.x86_64
---> Package patch.x86_64 0:2.6-6.el6 will be インストール
---> Package pax.x86_64 0:3.4-10.1.el6 will be インストール
---> Package perl-CGI.x86_64 0:3.51-141.el6_7.1 will be インストール
---> Package perl-ExtUtils-MakeMaker.x86_64 0:6.55-141.el6_7.1 will be インストール
--> 依存性の処理をしています: perl-devel のパッケージ: perl-ExtUtils-MakeMaker-6.55-141.el6_7.1.x86_64
---> Package perl-Test-Harness.x86_64 0:3.17-141.el6_7.1 will be インストール
---> Package perl-Test-Simple.x86_64 0:0.92-141.el6_7.1 will be インストール
---> Package time.x86_64 0:1.7-38.el6 will be インストール
---> Package tomcat7-el-2.2-api.noarch 0:7.0.54-2.jpp6 will be インストール
---> Package tomcat7-jsp-2.2-api.noarch 0:7.0.54-2.jpp6 will be インストール
---> Package tomcat7-servlet-3.0-api.noarch 0:7.0.54-2.jpp6 will be インストール
--> トランザクションの確認を実行しています。
---> Package cvs.x86_64 0:1.11.23-16.el6 will be インストール
---> Package libgcj.x86_64 0:4.4.7-16.el6 will be インストール
--> 依存性の処理をしています: zip >= 2.1 のパッケージ: libgcj-4.4.7-16.el6.x86_64
--> 依存性の処理をしています: libart_lgpl >= 2.1.0 のパッケージ: libgcj-4.4.7-16.el6.x86_64
---> Package perl-devel.x86_64 4:5.10.1-141.el6_7.1 will be インストール
--> 依存性の処理をしています: perl(ExtUtils::ParseXS) のパッケージ: 4:perl-devel-5.10.1-141.el6_7.1.x86_64
--> 依存性の処理をしています: gdbm-devel のパッケージ: 4:perl-devel-5.10.1-141.el6_7.1.x86_64
---> Package sinjdoc.x86_64 0:0.5-9.1.el6 will be インストール
--> 依存性の処理をしています: java_cup >= 0.10 のパッケージ: sinjdoc-0.5-9.1.el6.x86_64
---> Package xz-lzma-compat.x86_64 0:4.999.9-0.5.beta.20091007git.el6 will be インストール
--> 依存性の処理をしています: xz = 4.999.9-0.5.beta.20091007git.el6 のパッケージ: xz-lzma-compat-4.999.9-0.5.beta.20091007git.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package gdbm-devel.x86_64 0:1.8.0-38.el6 will be インストール
---> Package java-cup.noarch 2:0.11-0.a.3.jpp6 will be インストール
---> Package libart_lgpl.x86_64 0:2.3.20-5.1.el6 will be インストール
---> Package perl-ExtUtils-ParseXS.x86_64 1:2.2003.0-141.el6_7.1 will be インストール
---> Package xz.x86_64 0:4.999.9-0.5.beta.20091007git.el6 will be インストール
---> Package zip.x86_64 0:3.0-1.el6_7.1 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

============================================================================================================================
 パッケージ                                 アーキテクチャ バージョン                                リポジトリー      容量
============================================================================================================================
インストールしています:
 tomcat7-admin-webapps                      noarch         7.0.54-2.jpp6                             jpackage          41 k
 tomcat7-webapps                            noarch         7.0.54-2.jpp6                             jpackage         737 k
依存性関連でのインストールをします。:
 apache-commons-collections-tomcat5         noarch         3.2.1-6.jpp6                              jpackage          29 k
 apache-commons-daemon                      noarch         1:1.0.15-1.jpp6                           jpackage          52 k
 apache-commons-dbcp-tomcat5                noarch         1.3.0-0.r830852.4.jpp6                    jpackage         158 k
 apache-commons-logging                     noarch         1.1.3-2.jpp6                              jpackage          78 k
 apache-commons-pool-tomcat5                noarch         1.5.7-1.jpp6                              jpackage          78 k
 apache-taglibs-standard                    noarch         1.1.2-8.jpp6                              jpackage         299 k
 at                                         x86_64         3.1.10-48.el6                             base              61 k
 bc                                         x86_64         1.06.95-1.el6                             base             110 k
 cvs                                        x86_64         1.11.23-16.el6                            base             712 k
 ecj3                                       noarch         1:3.7-1.jpp6                              jpackage         1.0 M
 gdbm-devel                                 x86_64         1.8.0-38.el6                              base              25 k
 gettext                                    x86_64         0.17-18.el6                               base             1.8 M
 java-1.5.0-gcj                             x86_64         1.5.0.0-29.1.el6                          base             139 k
 java-cup                                   noarch         2:0.11-0.a.3.jpp6                         jpackage         104 k
 libart_lgpl                                x86_64         2.3.20-5.1.el6                            base              65 k
 libgcj                                     x86_64         4.4.7-16.el6                              base              19 M
 man                                        x86_64         1.6f-32.el6                               base             263 k
 patch                                      x86_64         2.6-6.el6                                 base              90 k
 pax                                        x86_64         3.4-10.1.el6                              base              69 k
 perl-CGI                                   x86_64         3.51-141.el6_7.1                          updates          209 k
 perl-ExtUtils-MakeMaker                    x86_64         6.55-141.el6_7.1                          updates          294 k
 perl-ExtUtils-ParseXS                      x86_64         1:2.2003.0-141.el6_7.1                    updates           46 k
 perl-Test-Harness                          x86_64         3.17-141.el6_7.1                          updates          232 k
 perl-Test-Simple                           x86_64         0.92-141.el6_7.1                          updates          113 k
 perl-devel                                 x86_64         4:5.10.1-141.el6_7.1                      updates          424 k
 redhat-lsb-core                            x86_64         4.0-7.el6.centos                          base              25 k
 sinjdoc                                    x86_64         0.5-9.1.el6                               base             705 k
 time                                       x86_64         1.7-38.el6                                base              26 k
 tomcat6-jsp-2.1-api                        noarch         6.0.33-2.jpp6                             jpackage          75 k
 tomcat6-servlet-2.5-api                    noarch         6.0.33-2.jpp6                             jpackage          89 k
 tomcat7                                    noarch         7.0.54-2.jpp6                             jpackage         103 k
 tomcat7-el-2.2-api                         noarch         7.0.54-2.jpp6                             jpackage          54 k
 tomcat7-jsp-2.2-api                        noarch         7.0.54-2.jpp6                             jpackage          82 k
 tomcat7-lib                                noarch         7.0.54-2.jpp6                             jpackage         4.9 M
 tomcat7-servlet-3.0-api                    noarch         7.0.54-2.jpp6                             jpackage         186 k
 xalan-j2                                   noarch         2.7.1-8.jbossorg_1.jpp6                   jpackage         3.1 M
 xz                                         x86_64         4.999.9-0.5.beta.20091007git.el6          base             137 k
 xz-lzma-compat                             x86_64         4.999.9-0.5.beta.20091007git.el6          base              16 k
 zip                                        x86_64         3.0-1.el6_7.1                             updates          259 k

トランザクションの要約
============================================================================================================================
インストール        41 パッケージ

合計容量: 35 M
インストール済み容量: 91 M
パッケージをダウンロードしています:
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
警告: RPMDB は yum 以外で変更されました。
  インストールしています  : tomcat6-servlet-2.5-api-6.0.33-2.jpp6.noarch                                               1/41 
  インストールしています  : tomcat7-servlet-3.0-api-7.0.54-2.jpp6.noarch                                               2/41 
  インストールしています  : tomcat7-jsp-2.2-api-7.0.54-2.jpp6.noarch                                                   3/41 
  インストールしています  : tomcat6-jsp-2.1-api-6.0.33-2.jpp6.noarch                                                   4/41 
  インストールしています  : cvs-1.11.23-16.el6.x86_64                                                                  5/41 
  インストールしています  : gettext-0.17-18.el6.x86_64                                                                 6/41 
  インストールしています  : bc-1.06.95-1.el6.x86_64                                                                    7/41 
  インストールしています  : patch-2.6-6.el6.x86_64                                                                     8/41 
  インストールしています  : 1:apache-commons-daemon-1.0.15-1.jpp6.noarch                                               9/41 
  インストールしています  : perl-CGI-3.51-141.el6_7.1.x86_64                                                          10/41 
  インストールしています  : apache-commons-collections-tomcat5-3.2.1-6.jpp6.noarch                                    11/41 
  インストールしています  : apache-commons-logging-1.1.3-2.jpp6.noarch                                                12/41 
  インストールしています  : 2:java-cup-0.11-0.a.3.jpp6.noarch                                                         13/41 
  インストールしています  : tomcat7-el-2.2-api-7.0.54-2.jpp6.noarch                                                   14/41 
  インストールしています  : zip-3.0-1.el6_7.1.x86_64                                                                  15/41 
  インストールしています  : apache-commons-dbcp-tomcat5-1.3.0-0.r830852.4.jpp6.noarch                                 16/41 
  インストールしています  : apache-commons-pool-tomcat5-1.5.7-1.jpp6.noarch                                           17/41 
  インストールしています  : xz-4.999.9-0.5.beta.20091007git.el6.x86_64                                                18/41 
  インストールしています  : xz-lzma-compat-4.999.9-0.5.beta.20091007git.el6.x86_64                                    19/41 
  インストールしています  : man-1.6f-32.el6.x86_64                                                                    20/41 
  インストールしています  : libart_lgpl-2.3.20-5.1.el6.x86_64                                                         21/41 
  インストールしています  : libgcj-4.4.7-16.el6.x86_64                                                                22/41 
  インストールしています  : java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64                                                    23/41 
  インストールしています  : sinjdoc-0.5-9.1.el6.x86_64                                                                24/41 
  インストールしています  : 1:ecj3-3.7-1.jpp6.noarch                                                                  25/41 
  インストールしています  : tomcat7-lib-7.0.54-2.jpp6.noarch                                                          26/41 
  インストールしています  : xalan-j2-2.7.1-8.jbossorg_1.jpp6.noarch                                                   27/41 
  インストールしています  : apache-taglibs-standard-1.1.2-8.jpp6.noarch                                               28/41 
  インストールしています  : pax-3.4-10.1.el6.x86_64                                                                   29/41 
  インストールしています  : gdbm-devel-1.8.0-38.el6.x86_64                                                            30/41 
  インストールしています  : 1:perl-ExtUtils-ParseXS-2.2003.0-141.el6_7.1.x86_64                                       31/41 
  インストールしています  : perl-ExtUtils-MakeMaker-6.55-141.el6_7.1.x86_64                                           32/41 
  インストールしています  : 4:perl-devel-5.10.1-141.el6_7.1.x86_64                                                    33/41 
  インストールしています  : perl-Test-Harness-3.17-141.el6_7.1.x86_64                                                 34/41 
  インストールしています  : perl-Test-Simple-0.92-141.el6_7.1.x86_64                                                  35/41 
  インストールしています  : at-3.1.10-48.el6.x86_64                                                                   36/41 
  インストールしています  : time-1.7-38.el6.x86_64                                                                    37/41 
  インストールしています  : redhat-lsb-core-4.0-7.el6.centos.x86_64                                                   38/41 
  インストールしています  : tomcat7-7.0.54-2.jpp6.noarch                                                              39/41 
  インストールしています  : tomcat7-admin-webapps-7.0.54-2.jpp6.noarch                                                40/41 
  インストールしています  : tomcat7-webapps-7.0.54-2.jpp6.noarch                                                      41/41 
  Verifying               : time-1.7-38.el6.x86_64                                                                     1/41 
  Verifying               : at-3.1.10-48.el6.x86_64                                                                    2/41 
  Verifying               : tomcat7-7.0.54-2.jpp6.noarch                                                               3/41 
  Verifying               : redhat-lsb-core-4.0-7.el6.centos.x86_64                                                    4/41 
  Verifying               : gdbm-devel-1.8.0-38.el6.x86_64                                                             5/41 
  Verifying               : 4:perl-devel-5.10.1-141.el6_7.1.x86_64                                                     6/41 
  Verifying               : pax-3.4-10.1.el6.x86_64                                                                    7/41 
  Verifying               : tomcat7-jsp-2.2-api-7.0.54-2.jpp6.noarch                                                   8/41 
  Verifying               : tomcat7-servlet-3.0-api-7.0.54-2.jpp6.noarch                                               9/41 
  Verifying               : libart_lgpl-2.3.20-5.1.el6.x86_64                                                         10/41 
  Verifying               : xz-4.999.9-0.5.beta.20091007git.el6.x86_64                                                11/41 
  Verifying               : sinjdoc-0.5-9.1.el6.x86_64                                                                12/41 
  Verifying               : tomcat7-admin-webapps-7.0.54-2.jpp6.noarch                                                13/41 
  Verifying               : tomcat6-servlet-2.5-api-6.0.33-2.jpp6.noarch                                              14/41 
  Verifying               : apache-commons-pool-tomcat5-1.5.7-1.jpp6.noarch                                           15/41 
  Verifying               : 1:ecj3-3.7-1.jpp6.noarch                                                                  16/41 
  Verifying               : man-1.6f-32.el6.x86_64                                                                    17/41 
  Verifying               : perl-Test-Simple-0.92-141.el6_7.1.x86_64                                                  18/41 
  Verifying               : apache-commons-dbcp-tomcat5-1.3.0-0.r830852.4.jpp6.noarch                                 19/41 
  Verifying               : libgcj-4.4.7-16.el6.x86_64                                                                20/41 
  Verifying               : zip-3.0-1.el6_7.1.x86_64                                                                  21/41 
  Verifying               : java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64                                                    22/41 
  Verifying               : tomcat7-el-2.2-api-7.0.54-2.jpp6.noarch                                                   23/41 
  Verifying               : tomcat6-jsp-2.1-api-6.0.33-2.jpp6.noarch                                                  24/41 
  Verifying               : xz-lzma-compat-4.999.9-0.5.beta.20091007git.el6.x86_64                                    25/41 
  Verifying               : perl-ExtUtils-MakeMaker-6.55-141.el6_7.1.x86_64                                           26/41 
  Verifying               : 2:java-cup-0.11-0.a.3.jpp6.noarch                                                         27/41 
  Verifying               : apache-commons-logging-1.1.3-2.jpp6.noarch                                                28/41 
  Verifying               : apache-commons-collections-tomcat5-3.2.1-6.jpp6.noarch                                    29/41 
  Verifying               : tomcat7-lib-7.0.54-2.jpp6.noarch                                                          30/41 
  Verifying               : perl-CGI-3.51-141.el6_7.1.x86_64                                                          31/41 
  Verifying               : gettext-0.17-18.el6.x86_64                                                                32/41 
  Verifying               : apache-taglibs-standard-1.1.2-8.jpp6.noarch                                               33/41 
  Verifying               : 1:apache-commons-daemon-1.0.15-1.jpp6.noarch                                              34/41 
  Verifying               : 1:perl-ExtUtils-ParseXS-2.2003.0-141.el6_7.1.x86_64                                       35/41 
  Verifying               : xalan-j2-2.7.1-8.jbossorg_1.jpp6.noarch                                                   36/41 
  Verifying               : patch-2.6-6.el6.x86_64                                                                    37/41 
  Verifying               : bc-1.06.95-1.el6.x86_64                                                                   38/41 
  Verifying               : cvs-1.11.23-16.el6.x86_64                                                                 39/41 
  Verifying               : tomcat7-webapps-7.0.54-2.jpp6.noarch                                                      40/41 
  Verifying               : perl-Test-Harness-3.17-141.el6_7.1.x86_64                                                 41/41 

インストール:
  tomcat7-admin-webapps.noarch 0:7.0.54-2.jpp6                    tomcat7-webapps.noarch 0:7.0.54-2.jpp6                   

依存性関連をインストールしました:
  apache-commons-collections-tomcat5.noarch 0:3.2.1-6.jpp6       apache-commons-daemon.noarch 1:1.0.15-1.jpp6               
  apache-commons-dbcp-tomcat5.noarch 0:1.3.0-0.r830852.4.jpp6    apache-commons-logging.noarch 0:1.1.3-2.jpp6               
  apache-commons-pool-tomcat5.noarch 0:1.5.7-1.jpp6              apache-taglibs-standard.noarch 0:1.1.2-8.jpp6              
  at.x86_64 0:3.1.10-48.el6                                      bc.x86_64 0:1.06.95-1.el6                                  
  cvs.x86_64 0:1.11.23-16.el6                                    ecj3.noarch 1:3.7-1.jpp6                                   
  gdbm-devel.x86_64 0:1.8.0-38.el6                               gettext.x86_64 0:0.17-18.el6                               
  java-1.5.0-gcj.x86_64 0:1.5.0.0-29.1.el6                       java-cup.noarch 2:0.11-0.a.3.jpp6                          
  libart_lgpl.x86_64 0:2.3.20-5.1.el6                            libgcj.x86_64 0:4.4.7-16.el6                               
  man.x86_64 0:1.6f-32.el6                                       patch.x86_64 0:2.6-6.el6                                   
  pax.x86_64 0:3.4-10.1.el6                                      perl-CGI.x86_64 0:3.51-141.el6_7.1                         
  perl-ExtUtils-MakeMaker.x86_64 0:6.55-141.el6_7.1              perl-ExtUtils-ParseXS.x86_64 1:2.2003.0-141.el6_7.1        
  perl-Test-Harness.x86_64 0:3.17-141.el6_7.1                    perl-Test-Simple.x86_64 0:0.92-141.el6_7.1                 
  perl-devel.x86_64 4:5.10.1-141.el6_7.1                         redhat-lsb-core.x86_64 0:4.0-7.el6.centos                  
  sinjdoc.x86_64 0:0.5-9.1.el6                                   time.x86_64 0:1.7-38.el6                                   
  tomcat6-jsp-2.1-api.noarch 0:6.0.33-2.jpp6                     tomcat6-servlet-2.5-api.noarch 0:6.0.33-2.jpp6             
  tomcat7.noarch 0:7.0.54-2.jpp6                                 tomcat7-el-2.2-api.noarch 0:7.0.54-2.jpp6                  
  tomcat7-jsp-2.2-api.noarch 0:7.0.54-2.jpp6                     tomcat7-lib.noarch 0:7.0.54-2.jpp6                         
  tomcat7-servlet-3.0-api.noarch 0:7.0.54-2.jpp6                 xalan-j2.noarch 0:2.7.1-8.jbossorg_1.jpp6                  
  xz.x86_64 0:4.999.9-0.5.beta.20091007git.el6                   xz-lzma-compat.x86_64 0:4.999.9-0.5.beta.20091007git.el6   
  zip.x86_64 0:3.0-1.el6_7.1                                    

完了しました!

今度はうまくインストールされました。

Apacheとの連携

↓ちなみにApacheのインストールついては別記事上げてます

【CentOS6】Apache2.2インストール&設定 - 忘備録

モジュールの追加

/etc/httpd/conf/httpd.conf

# 無効(コメントアウト)になっていないことを確認
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

プロキシ設定

まずはApache側。

httpd.confに書いても良いみたいですが、自分はバーチャルホストを設定しているため、そちらの設定ファイルに記述しました。

/etc/httpd/conf.d/vhosts/example.conf

<VirtualHost *:80>
  ServerName example.co.jp
#〜〜〜〜〜〜(中略)〜〜〜〜〜〜〜〜
  # サーバのルートに対する接続を、8009ポートに転送するという設定
  <Location />
     ProxyPass ajp://localhost:8009/
  </Location>
</VirtualHost>

続いてTomcat側。

/etc/tomcat7/server.xml

    <!-- 無効(コメントアウト)になっていないこと確認 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Tomcatの起動と自動起動設定

# 起動
$ service tomcat7 start
Starting tomcat7:                                          [  OK  ]
# 自動起動設定の確認
$ chkconfig | grep tomcat7
tomcat7         0:off  1:off  2:off  3:off  4:off  5:off  6:off
# 自動起動をON
$ chkconfig tomcat7 on
# 確認
$ chkconfig | grep tomcat7
tomcat7         0:off  1:off  2:on   3:on   4:on   5:on   6:off

本来ここまでくれば、tomcatにアクセスできるのですが、あることをしないと今回の手順ではコンパイルエラーで動きません。

/var/log/tomcat7/catalina.out

3 03, 2016 11:37:27 午後 org.apache.jasper.compiler.JDTCompiler$1 findType
重大: Compilation error
org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
    at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(Unknown Source)
    at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:231)
    at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:187)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromVariantTypeSignature(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeArgumentsFromSignature(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethod(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethods(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(Unknown Source)
    at org.eclipse.jdt.internal.compiler.Compiler.accept(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.getPackage(Unknown Source)
    at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.internalResolveLeafType(Unknown Source)
    at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.internalResolveType(Unknown Source)
    at org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference.resolveType(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypeFor(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTypesForFieldsAndMethods(Unknown Source)
    at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(Unknown Source)
    at org.eclipse.jdt.internal.compiler.Compiler.process(Unknown Source)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Unknown Source)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:466)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:193)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

調べてるうちに↓の記事に行き着き

CentOS6にJDK8・Tomcat7の環境を構築した時に詰まった話 | hacknote

いろいろ調べてみたところ、 Tomcat 7.0.54ではecjのバージョンを4系にする必要があるようでした。

出ているエラーの内容は違うようでしたが、原因は同じみたいで上記サイトを参考に対応したら動きました。

対応例

$ cd  /usr/share/java/tomcat7
$  ls -la | grep ecj
lrwxrwxrwx. 1 root root      24  33 21:45 2016 [ecj3].jar -> /usr/share/java/ecj3.jar
-rw-r--r--. 1 root root 1155139  730 16:59 2014 ecj3-7.0.54.jar
lrwxrwxrwx. 1 root root      15  33 21:45 2016 ecj3.jar -> ecj3-7.0.54.jar
# 消すのは怖いので古いecjを退避
$ mkdir bk
$ mv [ecj3].jar bk
$ mv ecj3-7.0.54.jar bk
$ mv ecj3.jar  bk
# ecj4.4を入手
$ wget http://central.maven.org/maven2/org/eclipse/jdt/core/compiler/ecj/4.4/ecj-4.4.jar
--2016-03-03 23:27:15--  http://central.maven.org/maven2/org/eclipse/jdt/core/compiler/ecj/4.4/ecj-4.4.jar
central.maven.org をDNSに問いあわせています... 23.235.47.209
central.maven.org|23.235.47.209|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 2298872 (2.2M) [application/java-archive]
`ecj-4.4.jar' に保存中

100%[==================================================================================>] 2,298,872    208K/s 時間 9.3s    

2016-03-03 23:27:25 (242 KB/s) - `ecj-4.4.jar' へ保存完了 [2298872/2298872]

tomcatを再起動してサーバにアクセスしてみます。

f:id:mktktmr:20160309062427p:plain

やっとこうまくいきました。

たぶん無理くりtomcat7入れたせいで依存関係が正しく解決できてないみたいです。

起動スクリプトのバージョン確認もうまくいきませんでした。

$ service tomcat7 version
Error: Could not find or load main class org.apache.catalina.util.ServerInfo

とりあえず動いたので、これについては後日調査します。

Tomcatマネージャの設定

Tomcatの管理ページへの認証設定を記述。

/etc/tomcat7/tomcat-users.xml

<tomcat-users>
  <role rolename="manager-gui"/>
  <user username="tomcat" password="password" roles="manager-gui"/>
</tomcat-users>

http://domain/manager/ にアクセスしてみます。

f:id:mktktmr:20160309062044p:plain

tomcat-users.xmlに設定したusernameとpasswordで認証をします。

f:id:mktktmr:20160309061503p:plain

管理ページにアクセスできます。

管理ページではGUIベースでデプロイやステータスのチェックなどができます。

ロールについて

Tomcat7管理ページのロールには以下のものがあります。

ロール 概要
manager-gui allows access to the HTML GUI and the status pages
manager-status allows access to the status pages only
manager-script allows access to the text interface and the status pages
manager-jmx allows access to the JMX proxy and the status pages
admin-gui allows access to the HTML GUI
admin-script allows access to the text interface

参考

ベリーキュート Blog » Blog Archive » Tomcat 7 インストールと設定

Apache側の設定 - Tomcatとの連携(mod_proxy_ajp) - Apache入門

CentOS6にJDK8・Tomcat7の環境を構築した時に詰まった話 | hacknote

:: JPackage Project | Home ::

Apache側の設定 - Tomcatとの連携(mod_proxy_ajp) - Apache入門

インフラエンジニアのメモ : Tomcat7のManager(管理画面)にアクセスできない

【CentOS6】ログ監視ツール

logwatch

logwatchは定期的にログのサマリーをメールで送ってくれるツールです。

導入することで、日々大量に吐かれるログから必要な情報だけをサマリーしてくれるため、ログの監視がぐっと楽になると思います。

インストール

$  yum search logwatch
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
epel/metalink                                                                                                                                       | 4.7 kB     00:00     
 * base: ftp.iij.ad.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
base                                                                                                                                                | 3.7 kB     00:00     
epel                                                                                                                                                | 4.3 kB     00:00     
epel/primary_db                                                                                                                                     | 5.8 MB     00:03     
extras                                                                                                                                              | 3.4 kB     00:00     
rpmforge                                                                                                                                            | 1.9 kB     00:00     
updates                                                                                                                                             | 3.4 kB     00:00     
========================================================================== N/S Matched: logwatch ==========================================================================
dmraid-events-logwatch.x86_64 : dmraid logwatch-based email reporting
hostapd-logwatch.x86_64 : Logwatch scripts for hostapd
fwlogwatch.x86_64 : Firewall log analyzer, report generator and realtime response agent
logwatch.noarch : A log file analysis program

  Name and summary matches only, use "search all" for everything.
$ yum install -y log watch
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: mirrors.hustunique.com
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
パッケージ log は利用できません。
パッケージ watch は利用できません。
エラー: 何もしません
$ yum install -y logwatch
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: mirrors.hustunique.com
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package logwatch.noarch 0:7.3.6-52.el6 will be インストール
--> 依存性の処理をしています: perl(strict) のパッケージ: logwatch-7.3.6-52.el6.noarch
--> 依存性の処理をしています: perl(POSIX) のパッケージ: logwatch-7.3.6-52.el6.noarch
--> 依存性の処理をしています: perl(Getopt::Long) のパッケージ: logwatch-7.3.6-52.el6.noarch
--> 依存性の処理をしています: perl(File::Temp) のパッケージ: logwatch-7.3.6-52.el6.noarch
--> 依存性の処理をしています: perl(Exporter) のパッケージ: logwatch-7.3.6-52.el6.noarch
--> 依存性の処理をしています: perl(Date::Manip) のパッケージ: logwatch-7.3.6-52.el6.noarch
--> 依存性の処理をしています: /usr/bin/perl のパッケージ: logwatch-7.3.6-52.el6.noarch
--> トランザクションの確認を実行しています。
---> Package perl.x86_64 4:5.10.1-141.el6_7.1 will be インストール
--> 依存性の処理をしています: perl-libs = 4:5.10.1-141.el6_7.1 のパッケージ: 4:perl-5.10.1-141.el6_7.1.x86_64
--> 依存性の処理をしています: perl-libs のパッケージ: 4:perl-5.10.1-141.el6_7.1.x86_64
--> 依存性の処理をしています: perl(version) のパッケージ: 4:perl-5.10.1-141.el6_7.1.x86_64
--> 依存性の処理をしています: perl(Pod::Simple) のパッケージ: 4:perl-5.10.1-141.el6_7.1.x86_64
--> 依存性の処理をしています: perl(Module::Pluggable) のパッケージ: 4:perl-5.10.1-141.el6_7.1.x86_64
--> 依存性の処理をしています: libperl.so()(64bit) のパッケージ: 4:perl-5.10.1-141.el6_7.1.x86_64
---> Package perl-Date-Manip.noarch 0:6.24-1.el6 will be インストール
--> 依存性の処理をしています: perl(YAML::Syck) のパッケージ: perl-Date-Manip-6.24-1.el6.noarch
--> トランザクションの確認を実行しています。
---> Package perl-Module-Pluggable.x86_64 1:3.90-141.el6_7.1 will be インストール
---> Package perl-Pod-Simple.x86_64 1:3.13-141.el6_7.1 will be インストール
--> 依存性の処理をしています: perl(Pod::Escapes) >= 1.04 のパッケージ: 1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64
---> Package perl-YAML-Syck.x86_64 0:1.07-4.el6 will be インストール
---> Package perl-libs.x86_64 4:5.10.1-141.el6_7.1 will be インストール
---> Package perl-version.x86_64 3:0.77-141.el6_7.1 will be インストール
--> トランザクションの確認を実行しています。
---> Package perl-Pod-Escapes.x86_64 1:1.04-141.el6_7.1 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

===========================================================================================================================================================================
 パッケージ                                      アーキテクチャ                   バージョン                                       リポジトリー                       容量
===========================================================================================================================================================================
インストールしています:
 logwatch                                        noarch                           7.3.6-52.el6                                     base                              302 k
依存性関連でのインストールをします。:
 perl                                            x86_64                           4:5.10.1-141.el6_7.1                             updates                            10 M
 perl-Date-Manip                                 noarch                           6.24-1.el6                                       base                              1.4 M
 perl-Module-Pluggable                           x86_64                           1:3.90-141.el6_7.1                               updates                            40 k
 perl-Pod-Escapes                                x86_64                           1:1.04-141.el6_7.1                               updates                            33 k
 perl-Pod-Simple                                 x86_64                           1:3.13-141.el6_7.1                               updates                           213 k
 perl-YAML-Syck                                  x86_64                           1.07-4.el6                                       base                               75 k
 perl-libs                                       x86_64                           4:5.10.1-141.el6_7.1                             updates                           579 k
 perl-version                                    x86_64                           3:0.77-141.el6_7.1                               updates                            52 k

トランザクションの要約
===========================================================================================================================================================================
インストール         9 パッケージ

総ダウンロード容量: 13 M
インストール済み容量: 47 M
パッケージをダウンロードしています:
(1/9): logwatch-7.3.6-52.el6.noarch.rpm                                                                                                             | 302 kB     00:00     
(2/9): perl-5.10.1-141.el6_7.1.x86_64.rpm                                                                                                           |  10 MB     00:03     
(3/9): perl-Date-Manip-6.24-1.el6.noarch.rpm                                                                                                        | 1.4 MB     00:01     
(4/9): perl-Module-Pluggable-3.90-141.el6_7.1.x86_64.rpm                                                                                            |  40 kB     00:00     
(5/9): perl-Pod-Escapes-1.04-141.el6_7.1.x86_64.rpm                                                                                                 |  33 kB     00:00     
(6/9): perl-Pod-Simple-3.13-141.el6_7.1.x86_64.rpm                                                                                                  | 213 kB     00:00     
(7/9): perl-YAML-Syck-1.07-4.el6.x86_64.rpm                                                                                                         |  75 kB     00:00     
(8/9): perl-libs-5.10.1-141.el6_7.1.x86_64.rpm                                                                                                      | 579 kB     00:00     
(9/9): perl-version-0.77-141.el6_7.1.x86_64.rpm                                                                                                     |  52 kB     00:00     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                                       1.4 MB/s |  13 MB     00:09     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : 1:perl-Pod-Escapes-1.04-141.el6_7.1.x86_64                                                                                                 1/9 
  インストールしています  : 1:perl-Module-Pluggable-3.90-141.el6_7.1.x86_64                                                                                            2/9 
  インストールしています  : 3:perl-version-0.77-141.el6_7.1.x86_64                                                                                                     3/9 
  インストールしています  : 4:perl-libs-5.10.1-141.el6_7.1.x86_64                                                                                                      4/9 
  インストールしています  : 1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64                                                                                                  5/9 
  インストールしています  : 4:perl-5.10.1-141.el6_7.1.x86_64                                                                                                           6/9 
  インストールしています  : perl-YAML-Syck-1.07-4.el6.x86_64                                                                                                           7/9 
  インストールしています  : perl-Date-Manip-6.24-1.el6.noarch                                                                                                          8/9 
  インストールしています  : logwatch-7.3.6-52.el6.noarch                                                                                                               9/9 
  Verifying               : 1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64                                                                                                  1/9 
  Verifying               : 1:perl-Pod-Escapes-1.04-141.el6_7.1.x86_64                                                                                                 2/9 
  Verifying               : perl-Date-Manip-6.24-1.el6.noarch                                                                                                          3/9 
  Verifying               : logwatch-7.3.6-52.el6.noarch                                                                                                               4/9 
  Verifying               : 1:perl-Module-Pluggable-3.90-141.el6_7.1.x86_64                                                                                            5/9 
  Verifying               : perl-YAML-Syck-1.07-4.el6.x86_64                                                                                                           6/9 
  Verifying               : 3:perl-version-0.77-141.el6_7.1.x86_64                                                                                                     7/9 
  Verifying               : 4:perl-libs-5.10.1-141.el6_7.1.x86_64                                                                                                      8/9 
  Verifying               : 4:perl-5.10.1-141.el6_7.1.x86_64                                                                                                           9/9 

インストール:
  logwatch.noarch 0:7.3.6-52.el6                                                                                                                                           

依存性関連をインストールしました:
  perl.x86_64 4:5.10.1-141.el6_7.1          perl-Date-Manip.noarch 0:6.24-1.el6 perl-Module-Pluggable.x86_64 1:3.90-141.el6_7.1 perl-Pod-Escapes.x86_64 1:1.04-141.el6_7.1
  perl-Pod-Simple.x86_64 1:3.13-141.el6_7.1 perl-YAML-Syck.x86_64 0:1.07-4.el6  perl-libs.x86_64 4:5.10.1-141.el6_7.1           perl-version.x86_64 3:0.77-141.el6_7.1    

完了しました!

設定

デフォルトの設定ファイルは

/usr/share/logwatch/default.conf/logwatch.conf

で、独自に設定を変えたい場合は以下ファイルを変更する。

/etc/logwatch/conf/logwatch.conf

ちなみに、デフォルトから変更したい項目だけ記述しておけば良いです。

自分の場合は以下を変えました。

# デフォルトだとrootだが、gmail宛に飛ばすように変更
MailTo = sample@gmail.com

# デフォルトのメールクライアントのsendmailからmailxに変更
mailer = "mailx -t"

基本的な運用はcronでの日次実行(logwatchインストール時に/etc/cron.daily/0logwatchが作成される)になる。

なお、テストなどのために即時実行したい場合はlogwatchコマンドを叩けばよい。

$ logwatch 
You have old files in your logwatch tmpdir (/var/cache/logwatch):
    logwatch.dbppTw6E
    logwatch.sAUaElla
The directories listed above were most likely created by a
logwatch run that failed to complete successfully.  If so, you
may delete these directories.

Ignoring header field "MIME-Version: 1.0"
Ignoring header field "Content-Transfer-Encoding: 7bit"
Ignoring header field "Content-Type: text/plain; charset="iso-8859-1""

そして、以下のようなサマリがメールで飛んでくる。

 ################### Logwatch 7.3.6 (05/19/07) #################### 
        Processing Initiated: Fri Feb 26 03:27:03 2016
        Date Range Processed: yesterday
                              ( 2016-Feb-25 )
                              Period is day.
      Detail Level of Output: 0
              Type of Output: unformatted
           Logfiles for Host: localhost.localdomain
  ################################################################## 
 
 --------------------- clam-update Begin ------------------------ 

 Last ClamAV update process started at Thu Feb 25 03:43:01 2016
 
 Last Status:
    main.cvd is up to date (version: 55, sigs: 2424225, f-level: 60, builder: neo)
    Downloading daily-21407.cdiff [100%]
    Downloading daily-21408.cdiff [100%]
    Downloading daily-21409.cdiff [100%]
    Downloading daily-21410.cdiff [100%]
    daily.cld updated (version: 21410, sigs: 1854558, f-level: 63, builder: neo)
    bytecode.cvd is up to date (version: 271, sigs: 47, f-level: 63, builder: anvilleg)
    Database updated (4278830 signatures) from database.clamav.net (IP: 27.96.54.66)
 
 ---------------------- clam-update End ------------------------- 

 
 --------------------- pam_unix Begin ------------------------ 

 sshd:
    Authentication Failures:
       unknown (xxxxxxxxxxx.xxx.ftth.sample.com): 1 Time(s)
    Invalid Users:
       Unknown Account: 1 Time(s)
 
 su-l:
    Sessions Opened:
       hoge -> root: 5 Time(s)
 
 
 ---------------------- pam_unix End ------------------------- 

 
 --------------------- Postfix Begin ------------------------ 

    5.380M  Bytes accepted                         5,641,489
    8.114K  Bytes delivered                            8,309
 ========   ================================================
 
       22   Accepted                                 100.00%
 --------   ------------------------------------------------
       22   Total                                    100.00%
 ========   ================================================
 
        1   Removed from queue    
        3   Delivered             
       21   Deferred              
      310   Deferrals             
 
     1220   Connection failure (outbound) 
 
 
 
 ---------------------- Postfix End ------------------------- 

 
 --------------------- SSHD Begin ------------------------ 

 
 Illegal users from:
    XXX.XXX.XXX.XXX (xxxxxxxxxxx.xxx.ftth.sample.com): 1 time
 
 Users logging in through sshd:
    hoge:
       XXX.XXX.XXX.XXX (xxxxxxxxxxx.xxx.ftth.sample.com): 4 times
       XXX.XXX.XXX.XXX (xxxxxxxxxxx.xxx.ftth.sample.com): 1 time
 
 
 Received disconnect:
    11: disconnected by user : 5 Time(s)
 
 ---------------------- SSHD End ------------------------- 

 
 --------------------- yum Begin ------------------------ 

 
 Packages Installed:
    1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64
    4:perl-libs-5.10.1-141.el6_7.1.x86_64
    perl-YAML-Syck-1.07-4.el6.x86_64
    1:perl-Module-Pluggable-3.90-141.el6_7.1.x86_64
    logwatch-7.3.6-52.el6.noarch
    1:perl-Pod-Escapes-1.04-141.el6_7.1.x86_64
    4:perl-5.10.1-141.el6_7.1.x86_64
    perl-Date-Manip-6.24-1.el6.noarch
    3:perl-version-0.77-141.el6_7.1.x86_64
 
 ---------------------- yum End ------------------------- 

 
 --------------------- Disk Space Begin ------------------------ 

 Filesystem            Size  Used Avail Use% Mounted on
 /dev/mapper/VolGroup-lv_root
                        50G  1.3G   46G   3% /
 /dev/sda1             477M   57M  395M  13% /boot
 /dev/mapper/VolGroup-lv_home
                       240G   60M  228G   1% /home
 
 
 ---------------------- Disk Space End ------------------------- 

 
 ###################### Logwatch End ######################### 

特に、Linuxのpam認証に関する「pam_unix」やssh認証に関する「SSHD」セキュリティに関する重要な情報なので、有用ですね。

参考

第29回 「logwatch によるログの収集」

Logwatchでサーバ監視レポート - エーエイチレフ linuxサーバー技術情報

swatch

任意のログをリアルタイムにチェックしたり、メッセージのパターンを検知してメールを投げたりできるツールです。

インストール

前提として、EPELリポジトリの登録が必要です。

【CentOS6】サードパーティリポジトリの追加 - 忘備録

yum install -y swatch
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
epel/metalink                                                                          | 5.1 kB     00:00     
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.iij.ad.jp
base                                                                                   | 3.7 kB     00:00     
epel                                                                                   | 4.3 kB     00:00     
extras                                                                                 | 3.4 kB     00:00     
rpmforge                                                                               | 1.9 kB     00:00     
updates                                                                                | 3.4 kB     00:00     
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package swatch.noarch 0:3.2.3-7.el6 will be インストール
--> 依存性の処理をしています: perl(Time::HiRes) のパッケージ: swatch-3.2.3-7.el6.noarch
--> 依存性の処理をしています: perl(Date::Parse) のパッケージ: swatch-3.2.3-7.el6.noarch
--> 依存性の処理をしています: perl(Date::Format) のパッケージ: swatch-3.2.3-7.el6.noarch
--> 依存性の処理をしています: perl(Date::Calc) のパッケージ: swatch-3.2.3-7.el6.noarch
--> トランザクションの確認を実行しています。
---> Package perl-Date-Calc.noarch 0:6.3-2.el6 will be インストール
--> 依存性の処理をしています: perl(Bit::Vector) >= 7.1 のパッケージ: perl-Date-Calc-6.3-2.el6.noarch
--> 依存性の処理をしています: perl(Carp::Clan) のパッケージ: perl-Date-Calc-6.3-2.el6.noarch
--> 依存性の処理をしています: perl(Bit::Vector) のパッケージ: perl-Date-Calc-6.3-2.el6.noarch
---> Package perl-Time-HiRes.x86_64 4:1.9721-141.el6_7.1 will be インストール
---> Package perl-TimeDate.noarch 1:1.16-13.el6 will be インストール
--> トランザクションの確認を実行しています。
---> Package perl-Bit-Vector.x86_64 0:7.1-2.el6 will be インストール
---> Package perl-Carp-Clan.noarch 0:6.03-2.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================
 パッケージ                  アーキテクチャ     バージョン                          リポジトリー         容量
==============================================================================================================
インストールしています:
 swatch                      noarch             3.2.3-7.el6                         epel                 49 k
依存性関連でのインストールをします。:
 perl-Bit-Vector             x86_64             7.1-2.el6                           base                169 k
 perl-Carp-Clan              noarch             6.03-2.el6                          base                 25 k
 perl-Date-Calc              noarch             6.3-2.el6                           base                210 k
 perl-Time-HiRes             x86_64             4:1.9721-141.el6_7.1                updates              49 k
 perl-TimeDate               noarch             1:1.16-13.el6                       base                 37 k

トランザクションの要約
==============================================================================================================
インストール         6 パッケージ

総ダウンロード容量: 539 k
インストール済み容量: 1.4 M
パッケージをダウンロードしています:
(1/6): perl-Bit-Vector-7.1-2.el6.x86_64.rpm                                            | 169 kB     00:00     
(2/6): perl-Carp-Clan-6.03-2.el6.noarch.rpm                                            |  25 kB     00:00     
(3/6): perl-Date-Calc-6.3-2.el6.noarch.rpm                                             | 210 kB     00:00     
(4/6): perl-Time-HiRes-1.9721-141.el6_7.1.x86_64.rpm                                   |  49 kB     00:00     
(5/6): perl-TimeDate-1.16-13.el6.noarch.rpm                                            |  37 kB     00:01     
(6/6): swatch-3.2.3-7.el6.noarch.rpm                                                   |  49 kB     00:00     
--------------------------------------------------------------------------------------------------------------
合計                                                                          144 kB/s | 539 kB     00:03     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : perl-Carp-Clan-6.03-2.el6.noarch                                              1/6 
  インストールしています  : perl-Bit-Vector-7.1-2.el6.x86_64                                              2/6 
  インストールしています  : perl-Date-Calc-6.3-2.el6.noarch                                               3/6 
  インストールしています  : 4:perl-Time-HiRes-1.9721-141.el6_7.1.x86_64                                   4/6 
  インストールしています  : 1:perl-TimeDate-1.16-13.el6.noarch                                            5/6 
  インストールしています  : swatch-3.2.3-7.el6.noarch                                                     6/6 
  Verifying               : perl-Carp-Clan-6.03-2.el6.noarch                                              1/6 
  Verifying               : perl-Bit-Vector-7.1-2.el6.x86_64                                              2/6 
  Verifying               : perl-Date-Calc-6.3-2.el6.noarch                                               3/6 
  Verifying               : swatch-3.2.3-7.el6.noarch                                                     4/6 
  Verifying               : 1:perl-TimeDate-1.16-13.el6.noarch                                            5/6 
  Verifying               : 4:perl-Time-HiRes-1.9721-141.el6_7.1.x86_64                                   6/6 

インストール:
  swatch.noarch 0:3.2.3-7.el6                                                                                 

依存性関連をインストールしました:
  perl-Bit-Vector.x86_64 0:7.1-2.el6                perl-Carp-Clan.noarch 0:6.03-2.el6                        
  perl-Date-Calc.noarch 0:6.3-2.el6                 perl-Time-HiRes.x86_64 4:1.9721-141.el6_7.1               
  perl-TimeDate.noarch 1:1.16-13.el6               

完了しました!

デーモン起動スクリプト

毎回手動でswatchを起動するのは手間なので、起動スクリプトを作成します。

[2016.02.29] スクリプトに不具合があったので修正しました。詳しくはソースのコメントを参照

/etc/rc.d/init.d/swatch

#!/bin/sh
#
# swatch
#
# chkconfig: 2345 90 35
# description: swatch start/stop script
#
. /etc/rc.d/init.d/functions

#[ ! -d /var/log/swatch ] && mkdir -p /var/log/swatch

PATH=/bin:/sbin:/usr/bin:/usr/sbin

start() {
  ls /var/run/swatch_*.pid 1> /dev/null 2>&1
  if [ $? -ne 0 ]; then
    pno=0
    RET=0
    conflist=`ls /etc/swatch/conf/*.conf`
    if [ $? -ne 0 ]; then
        exit 1
    fi
    for conf in $conflist
    do
      log=`basename $conf | cut -d\. -f1`

      logPath=`find /var/log/ -type f -regex ".*/$log"`
      [ ! -n "$logPath" ] && logPath=`find /var/log/ -type f -regex ".*/$log.log"`

      if [ -n "$logPath" ]; then
        pno=`expr $pno + 1`
        # [2016.02.29] --script-dirオプションを追加しました。
        # この指定がないとスクリプト停止時に.swatch_script.*ファイルが削除されず、ホームディレクトリに溜まっていってしまいます。
        swatch -c $conf -t "$logPath" --daemon \
        --script-dir=/tmp/ \
        --pid-file /var/run/swatch_$pno.pid 1>> /var/log/swatch.log 2>& 1
        RET=$?
        [ $RET != 0 ] && return $RET
      else
        echo -n "error: not found log file"
        exit 1
      fi
    done

    if [ $pno -gt 0 ]; then
      echo
      [ $RET = 0 ] && touch /var/lock/subsys/swatch
    fi

    echo -n "Starting swatch"
    return $RET
  else
    echo -n "swatch already started"
  fi
}

stop() {
  ls /var/run/swatch_*.pid 1> /dev/null 2>&1
  if [ $? -eq 0 ]; then
    echo -n "Stopping swatch"
    for pid in /var/run/swatch_*.pid
    do
      kill $(cat $pid)
      rm -f $pid
    done
    echo
    rm -f /var/lock/subsys/swatch /tmp/.swatch_script.*
  else
    echo -n "swatch is not starting"
  fi
}

status() {
  ls /var/run/swatch_*.pid 1> /dev/null 2>&1
  if [ $? -eq 0 ]; then
    echo -n "swatch (pid"
    for pid in /var/run/swatch_*.pid
    do
      echo -n " `cat $pid`"
    done
    echo ") is running"
  else
    echo -n "swatch is stopped"
  fi
}

case "$1" in
  start)  start;;
  stop)    stop;;
  restart)stop && start;;
  status)  status;;
  *)      echo "Usage: swatch {start|stop|restart|status}" && exit 1;;
esac

exit $RET

スクリプトの概要は以下です。

  • /etc/swatch/conf/ 配下にある「*.conf」ファイルをswatchの-cオプションの引数にする
  • /var/log/{上記の設定ファイルの拡張子(.conf)を抜いたもの} をswatchの-tオプションの引数にする
  • /var/log/{上記の設定ファイルの拡張子(.conf)を抜いたもの}がない場合、{左記に.logを加えたもの} をswatchの-tオプションの引数にする
  • 「echo」アクションの出力先を /var/log/swatch.log にする

文だとイマイチ分からないので例を挙げると

/etc/swatch/conf/secure.conf と /etc/swatch/conf/yum.conf という設定ファイルがあった場合、

swatch -c secure.conf -t secure

swatch -c yum.conf -t yum.log

が実行されます。

実行と自動起動設定

とりあえず実行

$ service swatch start

んで、自動起動するスクリプトとして実行するには、

起動スクリプトとして登録して。。。

$ chkconfig --add swatch

OS起動時にスクリプトが起動するように設定しておきます。

$ chkconfig swatch on

確認

$ chkconfig | grep swatch
swatch          0:off  1:off  2:on   3:on   4:on   5:on   6:off

設定

swatchの設定ファイルは監視するログファイルごとに、以下ディレクトリに作る

/etc/swatch/conf/

/etc/swatch/conf/secure.conf

##login
watchfor   /su(pam_unix)|session opened for user root/i
        echo
        pipe "mail -s 'TELNET_Session_Opend_Log (root)' sample@gmail.com"

##ftp
watchfor   /ftp.*session opened/i
        echo
        pipe "mail -s 'FTP_Session_Opend_Log' sample@gmail.com"

##ssh
watchfor   /sshd.*session opened/i
        echo
        pipe "mail -s SSH_Session_Opend_Log sample@gmail.com"

swatchの設定ファイルの書式は以下です。

watchfor /パターン/
    アクション

設定されたパターンが監視対象のログファイルに出力されると、アクションが実行されます。

ちなみにパターンはPerl正規表現で「/パターン/i」と i をつけることで大文字・小文字を無視することができます。

アクションには以下のように、いくらか種類があります。

アクション 概要
echo 検索パターンにマッチした行を標準出力に渡す。
mail 検索パターンにマッチした行をメール通知する。
pipe 検索パターンにマッチした行をパイプを通して外部コマンドに渡す。
threshold 連続してマッチした行の表示を指定回数になるまで表示しないようにする。
throttle 連続してマッチした行の検出を一定時間抑止する。

mailというメールで通知するためのアクションが用意されているのですが、例で挙げているsecure.confのアクションはpipeを使っており、ログ出力をmailコマンドに渡しています。

なぜこんな面倒をしているかというと、mailアクションでは内部的にsendmailが利用されていて、sendmailだと都合が悪いため(理由は割愛)mailコマンドを利用するようにしています。

参考

サーバのログを監視するSwatchの導入方法と使い方を解説 | OXY NOTES

Swatchによるリアルタイムログ監視システムを構築する【前編】 | 情シスハック

Linuxexpert - Swatchパターン&ルール記述例-Tips/Swatchパターン&ルール記述例-PukiWiki

ドットコマンドと直接スクリプトを実行した時の違い - Webエンジニアの技術メモ 〜PHP、SQL、Linuxなど〜

/var/lock/subsys/について - さよならインターネット

[swatch: ログ監視] Debian Linux Server

。。。今回初めて起動スクリプトを独自に書いたんで、とても勉強になりました。

半分コピペですが

【CentOS6】サードパーティリポジトリの追加

よく使われると思われるEPELとRPMforgeリポジトリの追加方法をメモしておく

EPELリポジトリの追加

# 電子署名の公開鍵取得
$ rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
# EPELリポジトリの取得
# -i: インストール
# -v (-iに対するオプション): 操作対象のパッケージ名
# -h (-iに対するオプション): 進捗状況(#によるインジケータ)の表示
$ rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm を取得中
準備中...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

RPMforgeリポジトリの追加

# 電子署名の公開鍵取得
$ rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
# RPMforgeリポジトリの取得
# -i: インストール
# -v (-iに対するオプション): 操作対象のパッケージ名
# -h (-iに対するオプション): 進捗状況(#によるインジケータ)の表示
$ rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm を取得中
準備中...                ########################################### [100%]
   1:rpmforge-release           ########################################### [100%]

その他リポジトリについて

AdditionalResources/Repositories - CentOS Wiki

参考

@IT:rpmコマンドで警告が表示される