Trac のインストール

Trac を使ってみようかな、と思いました。
Trac のインストールとセットアップのメモです。一緒に Subversion もセットアップしました。


Debian なので apt-get 等で必要なパッケージをインストールします。

sudo apt-get install trac trac-ja-resource libapache2-mod-python subversion libapache2-svn

Subversion のリポジトリ作成

Apache がアクセスできるようにオーナを www-data に変更します。

cd /var/lib
sudo mkdir svn
sudo chown -R www-data:www-data svn
cd svn
sudo -u www-data svnadmin create test-repo1

dav_svn.conf の設定

sudo vi /etc/apache2/mods-available/dav_svn.conf

# dav_svn.conf - Example Subversion/Apache configuration
# For details and further options see the Apache user manual and
# the Subversion book.
# NOTE: for a setup with multiple vhosts, you will want to do this
# configuration in /etc/apache2/sites-available/*, not here.

# <Location URL> ... </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
# Note, a literal /svn should NOT exist in your document root.
<Location /svn>

# Uncomment this to enable the repository
DAV svn

# Set this to the path to your repository
#SVNPath /var/lib/svn
# Alternatively, use SVNParentPath if you have multiple repositories under
# under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).
# You need either SVNPath and SVNParentPath, but not both.
SVNParentPath /var/lib/svn

# Access control is done at 3 levels: (1) Apache authentication, via
# any of several methods. A "Basic Auth" section is commented out
# below. (2) Apache <Limit> and <LimitExcept>, also commented out
# below. (3) mod_authz_svn is a svn-specific authorization module
# which offers fine-grained read/write access control for paths
# within a repository. (The first two layers are coarse-grained; you
# can only enable/disable access to an entire repository.) Note that
# mod_authz_svn is noticeably slower than the other two layers, so if
# you don't need the fine-grained control, don't configure it.

# Basic Authentication is repository-wide. It is not secure unless
# you are using https. See the 'htpasswd' command to create and
# manage the password file - and the documentation for the
# 'auth_basic' and 'authn_file' modules, which you will need for this
# (enable them with 'a2enmod').
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd

# To enable authorization via mod_authz_svn
AuthzSVNAccessFile /etc/apache2/dav_svn.authz

# The following three lines allow anonymous read, but make
# committers authenticate themselves. It requires the 'authz_user'
# module (enable it with 'a2enmod').
Require valid-user


dav_svn.passwd の作成

Subversion と Trac の両方で使用するユーザとパスワードのファイルを作成します。
sudo htpasswd -bc /etc/apache2/dav_svn.passwd user1 password
sudo htpasswd -b /etc/apache2/dav_svn.passwd user2 password

dav_svn.authz の作成

このファイルにより Subversion のディレクトリ単位でのアクセス制御が可能になります。
sudo vi /etc/apache2/dav_svn.authz

group1 = user1,user2

* =

@group1 = rw

Trac のプロジェクト作成と設定

sudo mkdir /var/lib/trac
sudo chown www-data:www-data -R trac
sudo -u www-data trac-admin /var/lib/trac/test-proj1 initenv
Templates directory に日本語リソースのパスを指定します。

/var/lib% sudo -u www-data trac-admin /var/lib/trac/test-proj1 initenv
Creating a new Trac environment at /var/lib/trac/test-proj1

Trac will first ask a few questions about your environment
in order to initalize 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]> Test Project1

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]>

Please specify the type of version control system,
By default, it will be svn.

If you don't want to use Trac with version control integration,
choose the default here and don't specify a repository directory.
in the next question.

Repository type [svn]>

Please specify the absolute path to the version control
repository, or leave it blank to use Trac without a repository.
You can also set the repository location later.

Path to repository [/path/to/repos]> /var/lib/svn/test-repo1

Please enter location of Trac page templates.
Default is the location of the site-wide templates installed with Trac.

Templates directory [/usr/share/trac/templates]> /usr/share/trac-ja-resource/templates

Creating and Initializing Project
Installing default wiki pages
/usr/share/trac/wiki-default/TracInterfaceCustomization => TracInterfaceCustomization
/usr/share/trac/wiki-default/TracAccessibility => TracAccessibility
Indexing repository
Project environment for 'Test Project1' created.

You may now configure the environment by editing the file:


If you'd like to take this new project environment for a test drive,
try running the Trac standalone web server `tracd`:

tracd --port 8000 /var/lib/trac/test-proj1

Then point your browser to http://localhost:8000/test-proj1.
There you can also browse the documentation for your installed
version of Trac, including information on further setup (such as
deploying Trac to a real web server).

The latest documentation can also always be found on the project



Wiki の日本語リソースの設定を行います。
sudo -u www-data trac-admin /var/lib/trac/test-proj1 wiki load /usr/share/trac-ja-resource/wiki-default

Apache の設定を行います。
sudo vi /etc/apache2/sites-available/trac

<Location /projects>
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracUriRoot /projects
PythonOption TracEnvParentDir "/var/lib/trac"

<LocationMatch /projects/[^/]+/login>
AuthType Basic
AuthName "Trac"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user

sudo a2ensite trac
sudo /etc/init.d/apache2 reload

Trac の権限設定

ログイン前は anonymous 権限です。
ログインすると authenticated グループに所属します。
authenticated は anonymous からパーミッションを継承します。
ここでは anonymous から作成・編集の権限を削除し、authenticated に全権限を付与します。

anonymous によるチケットの作成編集、wiki の作成編集を禁止します。
sudo -u www-data trac-admin /var/lib/trac/test-proj1 permission remove anonymous TICKET_CREATE TICKET_MODIFY WIKI_CREATE WIKI_MODIFY

sudo -u www-data trac-admin /var/lib/trac/test-proj1 permission add authenticated TRAC_ADMIN


チケットの種類、プライオリティ、コンポーネント、バージョン をカスタマイズします。

sudo -u www-data trac-admin /var/lib/trac/test-proj1 ticket_type remove enhancement
sudo -u www-data trac-admin /var/lib/trac/test-proj1 ticket_type change defect defect:不具合
sudo -u www-data trac-admin /var/lib/trac/test-proj1 ticket_type change task task:タスク

sudo -u www-data trac-admin /var/lib/trac/test-proj1 priority change blocker blocker:最優先
sudo -u www-data trac-admin /var/lib/trac/test-proj1 priority change critical critical:高
sudo -u www-data trac-admin /var/lib/trac/test-proj1 priority change major major:中
sudo -u www-data trac-admin /var/lib/trac/test-proj1 priority change minor minor:低
sudo -u www-data trac-admin /var/lib/trac/test-proj1 priority change trivial trivial:微

sudo -u www-data trac-admin /var/lib/trac/test-proj1 component remove component1
sudo -u www-data trac-admin /var/lib/trac/test-proj1 component remove component2
sudo -u www-data trac-admin /var/lib/trac/test-proj1 component add 基本設計 somebody
sudo -u www-data trac-admin /var/lib/trac/test-proj1 component add プロトタイプ somebody

sudo -u www-data trac-admin /var/lib/trac/test-proj1 version remove 2.0

sudo -u www-data trac-admin /var/lib/trac/test-proj1


チケット登録画面のプルダウン項目のデフォルト値の設定と、担当者(Asign to)をプルダウンに変更する設定を行います。
trac.ini の [ticket] セクションでカスタマイズします。
sudo -u www-data vi /var/lib/trac/test-proj1/conf/trac.ini

default_component = 基本設計
default_milestone = 基本設計書
default_priority = major:中
default_type = task:タスク
default_version = 1.0
restrict_owner = true

trac.ticket.report.* = disabled

あと、メール送信の設定も trac.ini の中で行うことになりますが、今回はここまで。

0 件のコメント: