Changes between Initial Version and Version 1 of waue/Trac


Ignore:
Timestamp:
Feb 9, 2009, 6:05:22 PM (15 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/Trac

    v1 v1  
     1= Trac on Ubuntu =
     2
     3== 緣由 ==
     4由於Jazz大力推薦,使用Trac已經好一陣子,覺得是一個不錯的文件工作管理系統。不過都用Jazz架好的系統,也想要自己試一下怎麼安裝架設。除此之外,trac的預設CSS還有更符合個人瀏覽習慣的改進空間,加上一些trac的plug in也想試試看。 我的安裝環境於 Ubuntu 8.04 & trac 0.11,參考主要是官方網站:
     5
     6[http://trac.edgewall.org/wiki/TracInstallPlatforms 安裝Trac於各種不同作業系統的HowTo]
     7
     8雖然官網介紹得很詳盡,不過還是有些小細節要注意,安裝方法如下:
     9
     10= OS 安裝 =
     11
     12== 查看 Ubuntu 機器資訊 ==
     13{{{
     14waue@ubuntu:~$ cat /etc/lsb-release
     15DISTRIB_ID=Ubuntu
     16DISTRIB_RELEASE=8.04
     17DISTRIB_CODENAME=hardy
     18DISTRIB_DESCRIPTION="Ubuntu 8.04.1"
     19waue@ubuntu:~$
     20
     21}}}
     22
     23= Trac 0.11 安裝 =
     24== 1. 軟體套件 ==
     25
     26
     27安裝 apache, setuptools and some libraries:
     28
     29{{{
     30sudo apt-get install apache2 libapache2-mod-python \
     31     libapache2-svn python-setuptools subversion python-subversion
     32sudo easy_install Trac
     33}}}
     34
     35=== 若要安裝 Bitten  ===
     36雖然是選項,但我有安裝。
     37
     38{{{
     39# Needed for bitten's trac 10.4 compatiblity.
     40sudo apt-get install python-clearsilver
     41# Needed for bitten unitest.
     42sudo easy_install http://darcs.idyll.org/~t/projects/figleaf-latest.tar.gz
     43
     44}}}
     45
     46== 2. 新增 Trac 環境目錄 ==
     47
     48|| 名稱 || 目錄 ||
     49|| Trac專案根目錄 || /var/lib/trac ||
     50|| Trac專案項目目錄 || /var/lib/trac/waue ||
     51|| 瀏覽目錄 || http://gm1.nchc.org.tw/waue ||
     52|| 版本控制跟目錄 || /var/lib/svn ||
     53
     54
     55設定此目錄可以讓apache有讀寫權限
     56
     57{{{
     58sudo mkdir /var/lib/trac
     59sudo chown www-data:www-data /var/lib/trac
     60}}}
     61
     62== 3. 設定 Apache2 ==
     63
     64接下來是設定trac整合到apache的步驟,先創立一個trac模型
     65
     66{{{
     67sudo vi /etc/apache2/sites-available/trac
     68}}}
     69
     70填入此模型的內容
     71
     72{{{
     73<VirtualHost *>
     74        ServerAdmin waue0920@gmail.com
     75        ServerName gm1.nchc.org.tw
     76        DocumentRoot /var/www
     77        ErrorLog /var/log/apache2/error.trac.log
     78        CustomLog /var/log/apache2/access.trac.log combined
     79
     80        <Location /waue>
     81                SetHandler mod_python
     82                PythonInterpreter main_interpreter
     83                PythonHandler trac.web.modpython_frontend
     84                PythonOption TracEnvParentDir /var/lib/trac
     85                PythonOption TracUriRoot /waue
     86                PythonOption PYTHON_EGG_CACHE /tmp
     87        </Location>
     88
     89        # use the following for one authorization for all projects
     90        # (names containing "-" are not detected):
     91        <LocationMatch "/waue/[[:alnum:]]+/login">
     92            AuthType Basic
     93            AuthName "trac"
     94            AuthUserFile /etc/apache2/dav_svn.passwd
     95            Require valid-user
     96        </LocationMatch>
     97
     98</VirtualHost>
     99}}}
     100
     101然後,取消default模板,換成剛剛的trac模板,然後重新啟動apache
     102
     103{{{
     104sudo a2dissite default
     105sudo a2ensite trac
     106sudo  /etc/init.d/apache2 reload
     107}}}
     108
     109
     110== 4. 啟動 ==
     111=== SVN ===
     112讓trac有版本控制的功能:
     113{{{
     114sudo mkdir /var/lib/svn
     115sudo svnadmin create /var/lib/svn/waue
     116}}}
     117
     118增加apache可以存取的目錄權限:
     119{{{
     120sudo chown -R www-data /var/lib/svn
     121sudo chown -R www-data /usr/share/trac
     122sudo  /etc/init.d/apache2 reload
     123}}}
     124
     125ps: References: [http://abbeyworkshop.com/howto/misc/svn01/ Commands populate files into SVN repository]
     126
     127=== Mercurial ===
     128
     129沒裝,不知道效果,原文如下:
     130
     131An 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]
     132
     133=== Trac ===
     134{{{/var/lib/trac/waue}}}是我trac中的專案路徑,更改其權限
     135
     136{{{
     137sudo mkdir /var/lib/trac
     138sudo trac-admin /var/lib/trac/waue initenv
     139}}}
     140
     141執行trac-admin這個指令會有query詢問環境參數如何設定:
     142
     143 * Project Name [My Project]>''' {{{waue}}} '''
     144 * Database connection string [sqlite:db/trac.db]> ''' [Enter鍵] '''
     145 * Repository type [svn]> ''' [Enter鍵] '''
     146 * Path to repository [/path/to/repos]> ''' /var/lib/trac/waue '''
     147
     148接著設定權限
     149{{{
     150sudo chown -R www-data /var/lib/trac
     151}}}
     152
     153
     154接著在瀏覽器輸入你的網址http://localhost/waue就可以看到囉!
     155 '''!http://localhost/waue'''
     156
     157更完整的Mod_Python設定,可以看 [http://trac.edgewall.org/wiki/TracModPython TracModPython]
     158
     159
     160== 5. 設定svn ==
     161修改 {{{/etc/apache2/mods-available/dav_svn.conf}}}
     162
     163{{{ 
     164<Location /svn>
     165    # Uncomment this to enable the repository,
     166    DAV svn
     167
     168    # Set this to the path to your repository
     169    SVNParentPath /var/lib/svn
     170</Location>
     171}}}
     172
     173
     174== 6. Plugin ==
     175
     176=== apt-get trac plugins  ===
     177{{{
     178sudo apt-get install build-essential graphviz htmldoc enscript
     179}}}
     180=== Easy_install Trac plugins ===
     181{{{
     182sudo easy_install http://svn.edgewall.org/repos/genshi/trunk/
     183sudo easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk
     184sudo easy_install http://trac-hacks.org/svn/customfieldadminplugin/0.11
     185sudo easy_install http://trac-hacks.org/svn/eclipsetracplugin/tracrpcext/0.10
     186sudo easy_install http://trac-hacks.org/svn/iniadminplugin/0.11
     187sudo easy_install http://trac-hacks.org/svn/masterticketsplugin/0.11
     188sudo easy_install http://trac-hacks.org/svn/pagetopdfplugin/0.10/
     189sudo easy_install http://trac-hacks.org/svn/progressmetermacro/0.11
     190sudo easy_install http://trac-hacks.org/svn/ticketdeleteplugin/0.11
     191sudo easy_install http://trac-hacks.org/svn/tracwysiwygplugin/0.11
     192sudo easy_install http://wikinotification.ufsoft.org/svn/trunk
     193}}}
     194 
     195== 7. Adding Authentication ==
     196
     197=== 權限設定 ===
     198用 `htpasswd -c` 來創建 password 檔:
     199
     200{{{
     201$ htpasswd -c /etc/apache2/dav_svn.passwd admin
     202New password: <type password>
     203Re-type new password: <type password again>
     204Adding password for user admin
     205}}}
     206
     207增加使用者也是用htpasswd,但不要加參數 "-c"
     208{{{
     209$ htpasswd /etc/apache2/dav_svn.passwd waue
     210New password: <type password>
     211Re-type new password: <type password again>
     212Adding password for user waue
     213}}}
     214
     215設定Trac的login到Apache的模型(sudo vi /etc/apache2/sites-available/trac):
     216{{{
     217<Location "/trac/login">
     218  AuthType Basic
     219  AuthName "Trac"
     220  AuthUserFile /etc/apache2/dav_svn.passwd
     221  Require valid-user
     222</Location>
     223}}}
     224
     225=== 多個專案 ===
     226
     227如果你有很多的project要管理,可以用下面的方法來設定多個專案:
     228{{{
     229<LocationMatch "/trac/[^/]+/login">
     230  AuthType Basic
     231  AuthName "Trac"
     232  AuthUserFile /etc/apache2/dav_svn.passwd
     233  Require valid-user
     234</LocationMatch>
     235}}}
     236
     237=== 更安全的作法 ===
     238安全因素考量,建立SSL連線;或AuthType用「Digest」代替 「Basic」. 更多 [http://httpd.apache.org/docs/2.0/ Apache HTTPD documentation] 。
     239
     240{{{
     241<Location "/trac/login">
     242    LoadModule auth_digest_module /usr/lib/apache2/modules/mod_auth_digest.so
     243    AuthType Digest
     244    AuthName "trac"
     245    AuthDigestDomain /trac
     246    AuthUserFile /etc/apache2/dav_svn.passwd
     247    Require valid-user
     248</Location>
     249}}}
     250新增 .htpasswd file with htdigest instead of htpasswd as follows:
     251{{{
     252# htdigest /etc/apache2/dav_svn.passwd trac admin
     253}}}
     254where the "trac" parameter above is the same as !AuthName above  ("Realm" in apache-docs).
     255
     256{{{
     257sudo chown www-data /etc/apache2/dav_svn.passwd
     258}}}
     259