wiki:waue/Trac

Version 1 (modified by waue, 15 years ago) (diff)

--

Trac on Ubuntu

緣由

由於Jazz大力推薦,使用Trac已經好一陣子,覺得是一個不錯的文件工作管理系統。不過都用Jazz架好的系統,也想要自己試一下怎麼安裝架設。除此之外,trac的預設CSS還有更符合個人瀏覽習慣的改進空間,加上一些trac的plug in也想試試看。 我的安裝環境於 Ubuntu 8.04 & trac 0.11,參考主要是官方網站:

安裝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

填入此模型的內容

<VirtualHost *>
        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

        <Location /waue>
                SetHandler mod_python
                PythonInterpreter main_interpreter
                PythonHandler trac.web.modpython_frontend
                PythonOption TracEnvParentDir /var/lib/trac
                PythonOption TracUriRoot /waue
                PythonOption PYTHON_EGG_CACHE /tmp
        </Location>

        # use the following for one authorization for all projects
        # (names containing "-" are not detected):
        <LocationMatch "/waue/[[:alnum:]]+/login">
            AuthType Basic
            AuthName "trac"
            AuthUserFile /etc/apache2/dav_svn.passwd
            Require valid-user
        </LocationMatch>

</VirtualHost>

然後,取消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: 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 Trac Mercurial? and the lastest version of mercurial from 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 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設定,可以看 TracModPython

5. 設定svn

修改 /etc/apache2/mods-available/dav_svn.conf

<Location /svn>
    # Uncomment this to enable the repository,
    DAV svn

    # Set this to the path to your repository
    SVNParentPath /var/lib/svn
</Location>

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: <type password>
Re-type new password: <type password again>
Adding password for user admin

增加使用者也是用htpasswd,但不要加參數 "-c"

$ htpasswd /etc/apache2/dav_svn.passwd waue
New password: <type password>
Re-type new password: <type password again>
Adding password for user waue

設定Trac的login到Apache的模型(sudo vi /etc/apache2/sites-available/trac):

<Location "/trac/login">
  AuthType Basic
  AuthName "Trac"
  AuthUserFile /etc/apache2/dav_svn.passwd
  Require valid-user
</Location>

多個專案

如果你有很多的project要管理,可以用下面的方法來設定多個專案:

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

更安全的作法

安全因素考量,建立SSL連線;或AuthType用「Digest」代替 「Basic」. 更多 Apache HTTPD documentation

<Location "/trac/login">
    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
</Location>

新增 .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