Changes between Initial Version and Version 1 of waue/TracInstall


Ignore:
Timestamp:
Feb 10, 2009, 11:50:24 AM (15 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/TracInstall

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