Tracをfcgiで動す

なんか久しぶりにTracをインストールしたら
古いバージョンと色々変わってたので作業メモ。

環境

OS: CentOS 5.5 (64bit)
Apache: 2.2.16
fastcgi: 2.4.6
Trac: Trac-0.12.ja1

Tracに必要なpythonライブラリ インスト

# yum install python-clearsilver.x86_64 python-sqlite2.x86_64 python-setuptools.noarch python-genshi.x86_64

python-sqliteはpython-sqlite2を入れないとTracのインストール時に

TracError: Cannot load Python bindings for SQLite

って怒られた。

Tracのインスト

以下のURLで日本語版が公開されているので、今回はこれを利用させて頂きました。

http://www.i-act.co.jp/project/products/products.html

# wget http://www.i-act.co.jp/project/products/downloads/Trac-0.12.ja1.zip
# unzip Trac-0.12.ja1.zip 
# cd Trac-0.12.ja1
# python setup.py install

古いバージョンはいろんなものをインストールしまくってけど最近のやつは必要最低限らしい。

Trac用ディレクトリの作成

# cd /path/to
# mkdir trac
# cd trac
# trac-admin myproject initenv
Creating a new Trac environment at /path/to/trac/myproject

Trac will first ask a few questions about your environment 
in order to initialize and prepare the project database.

 Please enter the name of your project.
 This name will be used in page titles and descriptions.

Project Name [My Project]> 
 
 Please specify the connection string for the database to use.
 By default, a local SQLite database is created in the environment
 directory. It is also possible to use an already existing
 PostgreSQL database (check the Trac documentation for the exact
 connection string syntax).

Database connection string [sqlite:db/trac.db]> 

Creating and Initializing Project
 Installing default wiki pages
<以下略>

レポジトリの設定はinitenvでやらなくなったっぽい。

これでインスト完了だが中身はスカスカ。昔は(ry
中身は別途↓のコマンドで作成。

# trac-admin myproject deploy /tmp/deploy
直接うつせないのでとりあえずtmpとかに

# cd myproject
# mv /tmp/deploy/cgi-bin .
# mv /tmp/deploy/htdocs .

Tracのインストールは大体終了

fastcgiで動かす

httpd.confで

# FastCGI
LoadModule fastcgi_module modules/mod_fastcgi.so
AddHandler fastcgi-script .fcgi
Include conf/extra/httpd-trac.conf

てしといて
httpd-trac.confで

FastCgiConfig -initial-env TRAC_ENV=/path/to/trac/myproject

ScriptAlias /trac /path/to/trac/myproject/cgi-bin/trac.fcgi
<Location "/trac">
    SetHandler fastcgi-script
    Order deny,allow
    Deny from all
    Allow from (適当に許可IP)
</Location>