Tracインストール

Apacheがインストール済みであることが前提。
Apache2.2.22インストール - i2bsの日記

Tracインストール

apt-get install libsqlite3-dev
pip install Babel
pip install Genshi
pip install Trac

Tracプロジェクト作成

mkdir -p /var/trac/.eggs
cd /var/trac
trac-admin project initenv
Project Name [My Project]> project
Database connection string [sqlite:db/trac.db]>

Tracユーザ作成

trac-admin /var/trac/project permission add username TRAC_ADMIN

mod_wsgiインストール

cd /usr/local/src
wget -c http://modwsgi.googlecode.com/files/mod_wsgi-3.3.tar.gz
tar zxvf mod_wsgi-3.3.tar.gz
cd mod_wsgi-3.3
./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/bin/python
make
make install

Apache設定

module読み込み

vi /usr/local/apache/conf/httpd.conf
LoadModule wsgi_module modules/mod_wsgi.so

VirtualHost設定ファイル作成

vi /usr/local/apache/conf/conf.d/xx.co.jp.conf
#<VirtualHost xx.xx.xx.xx:80>
#    ServerName xx.co.jp
#    DocumentRoot /usr/local/apache/vhosts/xx.co.jp/htdocs
#    ErrorLog /usr/local/apache/vhosts/xx.co.jp/logs/error_log
#    CustomLog "/usr/local/apache/vhosts/xx.co.jp/logs/access_log" combined
#</VirtualHost>

<VirtualHost xx.xx.xx.xx:443>
    ServerName xx.co.jp
    DocumentRoot /usr/local/apache/vhosts/xx.co.jp/htdocs
    ErrorLog /usr/local/apache/vhosts/xx.co.jp/logs/ssl_error_log
    CustomLog "/usr/local/apache/vhosts/xx.co.jp/logs/ssl_access_log" combined
    WSGIScriptAlias /trac /var/trac/project/trac.wsgi

    SSLEngine on
    SSLCertificateFile /usr/local/apache/vhosts/xx.co.jp/ssl.crt/server.crt
    SSLCertificateKeyFile /usr/local/apache/vhosts/xx.co.jp/ssl.key/server.key

    <Location />
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
        AuthType Basic
        AuthName "Trac"
        AuthUserFile /usr/local/apache/vhosts/xx.co.jp/etc/users
        Require valid-user
    </Location>
</VirtualHost>

<Directory /usr/local/apache/vhosts/xx.co.jp/htdocs>
    Options Includes ExecCGI FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

VirtualHostディレクトリ作成

mkdir -p /usr/local/apache/vhosts/xx.co.jp/{htdocs,logs,etc,ssl.crt,ssl.key}

自己署名証明書作成

cd $HOME
openssl genrsa -des3 -out server.key 1024
openssl rsa -in server.key -out server.key
openssl req -new -x509 -out server.crt -key server.key -days 365
mv -i server.crt /usr/local/apache/vhosts/xx.co.jp/ssl.crt/.
mv -i server.key /usr/local/apache/vhosts/xx.co.jp/ssl.key/.

htpasswd作成

/usr/local/apache/bin/htpasswd -c /usr/local/apache/vhosts/xx.co.jp/etc/users username

Tracwsgiスクリプト作成

vi /var/trac/project/trac.wsgi
#!/usr/bin/env python
# coding: utf-8

import os

os.environ['TRAC_ENV'] = '/var/trac/project'
os.environ['PYTHON_EGG_CACHE'] = '/var/trac/.eggs'

import trac.web.main
application = trac.web.main.dispatch_request
chmod 755 /var/trac/project/trac.wsgi
chown -R apache. /var/trac/project

Apache再起動

/usr/local/apache/bin/httpd -t
/etc/init.d/apache stop
/etc/init.d/apache start
ps -ef | grep httpd
tail /usr/local/apache/logs/error_log