Scientific Linux に Submin をインストールする

スポンサーリンク

さくらの VPS 上に構築した Scientific Linux 6.2 (32bit) 環境に、オープンソースの Subversion 管理フロントエンド Submin 2.0 をインストールしてみたので、その手順をメモしておく。Subversion のリポジトリブラウザである Trac にも対応する。また、今回は検証していないが、Git にも対応しているようだ。

Submin

ざっと見た感じ、次のような機能を備えている。

  • ユーザ管理機能

    • 追加、削除
    • パスワード変更
    • パスワード再発行
    • Commit があった際にメール通知
    • グループ分け
  • リポジトリ管理機能

    • 追加、削除
    • アクセス権の割当 (ユーザ、グループに対して、ディレクトリ単位で Read / Write)
    • Trac の導入

この他、詳細については下記の記事が参考になる。

スポンサーリンク

準備

OS のバージョンを確認する。

# cat /etc/redhat-release 
Scientific Linux release 6.2 (Carbon)

Python のバージョンを確認する。

# python -V
Python 2.6.6

yum で Apache のモジュール mod_dav_svn をインストールする。

# yum -y install mod_dav_svn

rpm で Apache のモジュール mod_python をインストールする。

# mkdir /usr/local/rpm
# cd /usr/local/rpm
# wget ftp://ftp.pbone.net/mirror/download.fedora.redhat.com/pub/fedora/epel/beta/6/i386/mod_python-3.3.1-14.el6.1.i686.rpm
# rpm -ivh mod_python-3.3.1-14.el6.1.i686.rpm

さらに rpm で SQLite のドライバをインストールする。

# wget ftp://ftp.pbone.net/mirror/ftp.centos.org/6.2/os/i386/Packages/apr-util-sqlite-1.3.9-3.el6_0.1.i686.rpm
# rpm -ivh apr-util-sqlite-1.3.9-3.el6_0.1.i686.rpm

Python のパッケージ setuptools をインストールする。

# cd /usr/local/src
# wget http://peak.telecommunity.com/dist/ez_setup.py
# python ez_setup.py

以上で必要なモジュール類のインストールが完了した。

Trac と Submin のインストール

Trac の日本語版をインストールする。

# cd /usr/local/src
# wget http://www.i-act.co.jp/project/products/downloads/Trac-0.12.3.ja2.zip
# unzip Trac-0.12.3.ja2.zip
# cd Trac-0.12.3.ja2
# python setup.py install

Trac がインストールされたか確認する。

# trac-admin -v
trac-admin 0.12.3.ja2

次に Submin をインストールする。

# cd /usr/local/src
# wget http://supermind.nl/submin/current/submin-2.0.3.tar.gz
# tar -xzf submin-2.0.3.tar.gz
# cd submin-2.0.3
# python setup.py install

以上で Trac と Submin のインストールが完了した。

初期設定

リポジトリ用のディレクトリを作成する。今回は /home 以下に配置したが、任意の位置で良い。

# mkdir /home/{svn,git,trac}
# chown apache /home/{svn,git,trac}
# mkdir /var/www/.python-eggs
# chown apache /var/www/.python-eggs

Submin の初期設定を行う。指定したメールアドレスにパスワード発行用のメールが届くので、正しく入力すること。

# submin2-admin /var/lib/submin initenv <管理者のメールアドレス>
  :
Path to the repository? [svn]> /home/svn
  :
Path to the git repositories? [git]> /home/git
  :
Path to trac environment? [trac]> /home/trac
  :
Hostname? [host.example.com]> 

Apache の conf ファイルをコピーする。

# cp /var/lib/submin/conf/apache.cgi.conf /etc/httpd/conf.d/submin.conf

必要な Apache モジュールをロードするように、submin.conf の先頭に以下を追加する。

# vi /etc/httpd/conf.d/submin.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule dbd_module modules/mod_dbd.so
LoadModule authz_svn_module modules/mod_authz_svn.so
LoadModule authn_dbd_module modules/mod_authn_dbd.so

※ https を必須にする場合は、さらに以下を追記する。ただし、後述のメールで届く URL は http:// になっているので、読み替える必要がある。

<LocationMatch "/(submin|svn|trac)/">
    SSLRequireSSL
</LocationMatch>

Apache の設定が間違っていないか確認する。

# /etc/init.d/httpd configtest
Syntax OK

Apache をリロードする。

# /etc/init.d/httpd reload

以上でインストールと初期設定が完了した。

使用方法

先の手順で入力したメールアドレスに、パスワード発行用の URL が届いている。本文中の URL をクリックすると、admin のパスワードが書かれたメールが送られてくる。

Submin から届くメール

Submin にアクセスし、メールに記載のパスワードでログインする。

ログイン画面

ユーザやグループ、リポジトリの追加は、メニュー左下のボタンから行える。

Submin のメニュー

Trac の設定

デフォルトの状態では、Trac 環境を構築 (Trac Environment -> Create) すると、アクセス権の設定に関わらず、認証なしに誰でも Browse Source が可能となっている。非公開レポジトリの場合は問題があるので、これを解決するために、レポジトリ毎に trac.ini を手動で書き換える。また、レポジトリ内のファイルの文字コードに UTF-8 を使用している場合、文字化けが発生するので、これも修正しておく。

vi /home/trac/<レポジトリ名>/conf/trac.ini
  :
[trac]
  :
authz_file = /var/lib/submin/conf/authz
authz_module_name = <レポジトリ名>
  :
default_charset = utf-8
  :
permission_policies = AuthzSourcePolicy
  :

これらの設定は、Submin で自動的にやって欲しいので、対処法を考えている。

エラーと原因

作業中に遭遇したエラーとその原因についてまとめておく。解決策はこれより前の本文中に書いてある。

python setup.py install を実行しようとすると、以下のエラーが表示される。

Traceback (most recent call last):
  File "setup.py", line 17, in <module>
    from setuptools import setup, find_packages

→ setuptools がインストールされていない。

Apache を再起動しようとすると、以下のエラーが表示される。

Starting httpd: Syntax error on line 46 of /etc/httpd/conf.d/submin.conf:
DBD: Can't load driver file apr_dbd_sqlite3.so
Starting httpd: Syntax error on line 41 of /etc/httpd/conf.d/submin.conf:
Invalid command 'DBDriver', perhaps misspelled or defined by a module not included in the server configuration

→ SQLite のドライバがインストールされていない。

Apache を再起動しようとすると、以下のエラーが表示される。

httpd: Syntax error on line 1009 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.d/submin.conf: Cannot load /etc/httpd/modules/mod_python.so into server: /etc/httpd/modules/mod_python.so: cannot open shared object file: No such file or directory

→ mod_python がインストールされていない。

リポジトリを新しく作成しようとすると、以下のエラーが表示される。

Error

We're very sorry, but an error occured:

could not create repository.
Please tell the administrator this error message and what caused it. Technical details (if any):

External command 'svnadmin' failed: svnadmin: '/home/svn/***' is a subdirectory of an existing repository rooted at '/home/svn/***'

→ ディレクトリの所有者が Apache になっていない。

パスワードが変更できない

新しいパスワードを入力して [save password] ボタンを押したあと、

Please verify your password

と表示されるので、再度同じものを入力して [save password] ボタンを押す必要がある。

Trac をインストールしようとすると、以下のエラーが発生する。

Whoops, an internal error occured:

trac-admin exited with exit status 256. Output from the command: Initenv for '/home/trac/***' failed. 
Failed to create environment.
Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

  [Errno 17] File exists: '/var/www/.python-eggs'

The Python egg cache directory is currently set to:

  /var/www/.python-eggs

Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

→ Apache の権限で /var/www/.python-eggs ディレクトリの作成に失敗している。

参考ページ

コメント

タイトルとURLをコピーしました