= Trac on Ubuntu =
== 緣由 ==
由於Jazz大力推薦,使用Trac已經好一陣子,覺得是一個不錯的文件工作管理系統。不過都用Jazz架好的系統,也想要自己試一下怎麼安裝架設。除此之外,trac的預設CSS還有更符合個人瀏覽習慣的改進空間,加上一些trac的plug in也想試試看。 我的安裝環境於 Ubuntu 8.04 & trac 0.11,參考主要是官方網站:
[http://trac.edgewall.org/wiki/TracInstallPlatforms 安裝Trac於各種不同作業系統的HowTo]
雖然官網介紹得很詳盡,不過還是有些小細節要注意,安裝方法如下:
= OS 安裝 =
== 查看 Ubuntu 機器資訊 ==
{{{
waue@ubuntu:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.1"
waue@ubuntu:~$
}}}
= Trac 0.11 安裝 =
== 1. 軟體套件 ==
安裝 apache, setuptools and some libraries:
{{{
sudo apt-get install apache2 libapache2-mod-python \
libapache2-svn python-setuptools subversion python-subversion
sudo easy_install Trac
}}}
=== 若要安裝 Bitten ===
雖然是選項,但我有安裝。
{{{
# Needed for bitten's trac 10.4 compatiblity.
sudo apt-get install python-clearsilver
# Needed for bitten unitest.
sudo easy_install http://darcs.idyll.org/~t/projects/figleaf-latest.tar.gz
}}}
== 2. 新增 Trac 環境目錄 ==
|| 名稱 || 目錄 ||
|| Trac專案根目錄 || /var/lib/trac ||
|| Trac專案項目目錄 || /var/lib/trac/waue ||
|| 瀏覽目錄 || http://gm1.nchc.org.tw/waue ||
|| 版本控制跟目錄 || /var/lib/svn ||
設定此目錄可以讓apache有讀寫權限
{{{
sudo mkdir /var/lib/trac
sudo chown www-data:www-data /var/lib/trac
}}}
== 3. 設定 Apache2 ==
接下來是設定trac整合到apache的步驟,先創立一個trac模型
{{{
sudo vi /etc/apache2/sites-available/trac
}}}
填入此模型的內容
{{{
ServerAdmin waue0920@gmail.com
ServerName gm1.nchc.org.tw
DocumentRoot /var/www
ErrorLog /var/log/apache2/error.trac.log
CustomLog /var/log/apache2/access.trac.log combined
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/lib/trac
PythonOption TracUriRoot /waue
PythonOption PYTHON_EGG_CACHE /tmp
# use the following for one authorization for all projects
# (names containing "-" are not detected):
AuthType Basic
AuthName "trac"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
}}}
然後,取消default模板,換成剛剛的trac模板,然後重新啟動apache
{{{
sudo a2dissite default
sudo a2ensite trac
sudo /etc/init.d/apache2 reload
}}}
== 4. 啟動 ==
=== SVN ===
讓trac有版本控制的功能:
{{{
sudo mkdir /var/lib/svn
sudo svnadmin create /var/lib/svn/waue
}}}
增加apache可以存取的目錄權限:
{{{
sudo chown -R www-data /var/lib/svn
sudo chown -R www-data /usr/share/trac
sudo /etc/init.d/apache2 reload
}}}
ps: References: [http://abbeyworkshop.com/howto/misc/svn01/ Commands populate files into SVN repository]
=== Mercurial ===
沒裝,不知道效果,原文如下:
An alternate solution is to use mercurial. if this case, do not setup any SVN (of course), indicate hg as the type of version control tool and the folder were your mercurial is. You will also need the mercurial plugin [wiki:TracMercurial Trac Mercurial] and the lastest version of mercurial from [https://help.ubuntu.com/community/UbuntuBackports#How%20to%20use the backports]
=== Trac ===
{{{/var/lib/trac/waue}}}是我trac中的專案路徑,更改其權限
{{{
sudo mkdir /var/lib/trac
sudo trac-admin /var/lib/trac/waue initenv
}}}
執行trac-admin這個指令會有query詢問環境參數如何設定:
* Project Name [My Project]>''' {{{waue}}} '''
* Database connection string [sqlite:db/trac.db]> ''' [Enter鍵] '''
* Repository type [svn]> ''' [Enter鍵] '''
* Path to repository [/path/to/repos]> ''' /var/lib/trac/waue '''
接著設定權限
{{{
sudo chown -R www-data /var/lib/trac
}}}
接著在瀏覽器輸入你的網址http://localhost/waue就可以看到囉!
'''!http://localhost/waue'''
更完整的Mod_Python設定,可以看 [http://trac.edgewall.org/wiki/TracModPython TracModPython]
== 5. 設定svn ==
修改 {{{/etc/apache2/mods-available/dav_svn.conf}}}
{{{
# Uncomment this to enable the repository,
DAV svn
# Set this to the path to your repository
SVNParentPath /var/lib/svn
}}}
== 6. Plugin ==
=== apt-get trac plugins ===
{{{
sudo apt-get install build-essential graphviz htmldoc enscript
}}}
=== Easy_install Trac plugins ===
{{{
sudo easy_install http://svn.edgewall.org/repos/genshi/trunk/
sudo easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk
sudo easy_install http://trac-hacks.org/svn/customfieldadminplugin/0.11
sudo easy_install http://trac-hacks.org/svn/eclipsetracplugin/tracrpcext/0.10
sudo easy_install http://trac-hacks.org/svn/iniadminplugin/0.11
sudo easy_install http://trac-hacks.org/svn/masterticketsplugin/0.11
sudo easy_install http://trac-hacks.org/svn/pagetopdfplugin/0.10/
sudo easy_install http://trac-hacks.org/svn/progressmetermacro/0.11
sudo easy_install http://trac-hacks.org/svn/ticketdeleteplugin/0.11
sudo easy_install http://trac-hacks.org/svn/tracwysiwygplugin/0.11
sudo easy_install http://wikinotification.ufsoft.org/svn/trunk
}}}
== 7. Adding Authentication ==
=== 權限設定 ===
用 `htpasswd -c` 來創建 password 檔:
{{{
$ htpasswd -c /etc/apache2/dav_svn.passwd admin
New password:
Re-type new password:
Adding password for user admin
}}}
增加使用者也是用htpasswd,但不要加參數 "-c"
{{{
$ htpasswd /etc/apache2/dav_svn.passwd waue
New password:
Re-type new password:
Adding password for user waue
}}}
設定Trac的login到Apache的模型(sudo vi /etc/apache2/sites-available/trac):
{{{
AuthType Basic
AuthName "Trac"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
}}}
=== 多個專案 ===
如果你有很多的project要管理,可以用下面的方法來設定多個專案:
{{{
AuthType Basic
AuthName "Trac"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
}}}
=== 更安全的作法 ===
安全因素考量,建立SSL連線;或AuthType用「Digest」代替 「Basic」. 更多 [http://httpd.apache.org/docs/2.0/ Apache HTTPD documentation] 。
{{{
LoadModule auth_digest_module /usr/lib/apache2/modules/mod_auth_digest.so
AuthType Digest
AuthName "trac"
AuthDigestDomain /trac
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
}}}
新增 .htpasswd file with htdigest instead of htpasswd as follows:
{{{
# htdigest /etc/apache2/dav_svn.passwd trac admin
}}}
where the "trac" parameter above is the same as !AuthName above ("Realm" in apache-docs).
{{{
sudo chown www-data /etc/apache2/dav_svn.passwd
}}}