Centos5.5安裝配置Trac1.0

 1.下載Trac安裝包並解壓

wget http://download.edgewall.org/trac/Trac-1.0.tar.gz
tar xvf Trac-1.0.tar.gz
cd Trac-1.0
2.解開之後查看一下其中的INSTALL文件,其中的Requirements一節詳細列出了安裝Trac所必須的軟件:
Python >= 2.5。(Centos 5.5不符合要求需要升級python)
Genshi >= 0.6。(在與Trac同一個網站上有下載)
可選的subversion >= 1.0(推薦>=1.1.x)和subversion的SWIG Python綁定
PySQLite,需要用於SQLite 3.x版本的PySQLite 2.x版
可運行python或CGI的Web服務器  

接下來就先解決這些前提條件
yum install -y wget curl curl-devel unzip ncurses-devel libxml2-devel openssl-devel libjpeg-devel libpng-devel freetype-de
vel autoconf automake libtool gcc gcc-c++ flex bison vim-enhanced python-devel pcre pcre-devel zlib zlib-devel libevent li
bevent-devel libtool-libs libtool-ltdl libtool-ltdl-devel bzip2 bzip2-devel gdb e2fsprogs-devel
 
安裝sqlite 3
yum install -y sqlite sqlite-devel

安裝subversion
yum install -y subversion subversion-devel

安裝python2.7
wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz
tar xvf Python-2.7.1.tgz
cd Python-2.7.1
./configure --enable-shared   //一定要加上--enable-shared參數,否則下面裝mod_python會報錯
make && make install
echo '/usr/local/lib' >> /etc/ld.so.conf && ldconfig
 
安裝python setuptools-0.6
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar xvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python setup.py install
 
安裝Genshi
wget http://ftp.edgewall.com/pub/genshi/Genshi-0.6.tar.gz
tar xvf Genshi-0.6.tar.gz
cd Genshi-0.6
python setup.py install
 
安裝PySQLite 2.x
wget http://pysqlite.googlecode.com/files/pysqlite-2.6.3.tar.gz
tar xvf pysqlite-2.6.3.tar.gz 
cd pysqlite-2.6.3
python setup.py install
 
安裝apache
wget http://archive.apache.org/dist/httpd/httpd-2.2.17.tar.gz
tar xvf httpd-2.2.17.tar.gz
cd cd httpd-2.2.17
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-proxy --enable-ssl --with-ssl
make && make install
vi /usr/local/apache/conf/httpd.conf
修改apache以apache用戶和apache用戶組運行
安裝mod_python-3.3.1(apache的python模塊)
wget http://archive.apache.org/dist/httpd/modpython/mod_python-3.3.1.tgz
tar xvf mod_python-3.3.1.tgz
cd mod_python-3.3.1
./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/local/bin/python --with-max-locks=32 --with-flex=/usr/bin/flex
make && make install
echo 'LoadModule python_module modules/mod_python.so'  >>/usr/local/apache/conf/httpd.conf
 
 
3.安裝trac
tar xvf Trac-1.0.tar.gz
cd Trac-1.0
python setup.py install
 
配置apache配置文件
我們將把 /data/trac 作爲項目的主目錄,所有新建的trac項目都放在該目錄下, 訪問URL爲 /trac/<項目名>。
 
在/usr/local/apache/conf/httpd.conf下添加Trac的配置:
<Location /trac>
    SetHandler mod_python
    PythonInterpreter main_interpreter
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnvParentDir /data/trac
    PythonOption TracUriRoot /trac/
    PythonOption PYTHON_EGG_CACHE /tmp/egg-cache
</Location>
 
然後在/data下建立trac目錄並設置權限
# cd /data
# mkdir trac
# chown apache.apache trac
 
啓動apache:
/usr/local/apache/bin/httpd -k start
接下來訪問http://localhost/trac,如果看到“Available Projects”字樣,就說明trac配置成功!
 
4.建立trac項目
下面要建立一個Trac的演示項目。進入 /data/trac,用trac-admin命令建立:
 
# cd /data/trac
# trac-admin domob initenv        (domob爲項目名稱,根據需要創建,接下來的提問全部按回車即可)
# chown -R apache.apache domob
 
然後訪問http://localhost/trac/domob,即可看到Trac的主界面了!
 
與svn結合:
如果想在Trac中查看subversion的代碼庫,首先建立用於放置代碼庫的目錄,並建立代碼庫:
# cd /data
# mkdir svn
# chown apache.apache svn
# cd svn
# svnadmin create domob        (domob爲代碼庫名稱,可以任意選擇)
# chown -R apache.apache domob
然後進入項目中的conf目錄, 修改trac.ini中的repository_dir變量爲代碼庫完整路徑即可。這個方法要求/data/trac下的所有內容必須屬於apache用戶,否則Trac會出錯。 
 
5.配置trac管理界面:
接下來需要配置好認證,這樣才能方便地通過瀏覽器來修改項目設置。
首先在 /data/trac 下建立 .htpasswd 文件,用來保存用戶名和密碼:
# cd /data/trac
# /usr/local/apache/bin/htpasswd -c .htpasswd root   (建立用戶root。如果.htpasswd文件存在,則不用加-c)
然後繼續修改 /usr/local/apache/conf/httpd.conf ,在末尾添加以下內容:
<LocationMatch "/trac/[^/]+/login">
    AuthType Basic
    AuthName "Trac"
    AuthUserFile /data/trac/.htpasswd
    Require valid-user
</LocationMatch>
然後重新啓動httpd:
# /etc/init.d/httpd restart
最後,進入/data/trac,給剛纔建好的domob項目設置權限:
# trac-admin domob permission add root TRAC_ADMIN
這樣,訪問 http://localhost/trac/domob,然後點擊上方菜單中的“Login”, 輸入用戶名root登錄之後,即可在右上角看到“Admin”菜單,點擊之後即可進入管理界面。
 
6.trac插件安裝
所有可用插件都可以在http://trac-hacks.org/ 網站上下載
(1).安裝賬號管理插件accountmanager
wget http://trac-hacks.org/changeset/latest/accountmanagerplugin/0.11?old_path=/&filename=accountmanagerplugin/0.11&format=zip
unzip accountmanagerplugin_0.11-r12573.zip
cd accountmanagerplugin/0.11
python setup.py bdist_egg
cp dist/TracAccountManager-0.4.2-py2.7.egg /data/trac/domob/plugins/
然後刷新trac管理頁面就出現Accounts管理了,進入下面的configuration中進行相應修改,使密碼文件指向/data/trac/.htpasswd,
然後就可以註釋apache關於trac認證配置了,以後就不用手動修改認證文件了
 
(2).安裝autocompleteusers插件
unzip autocompleteusersplugin-r12573.zip
cd autocompleteusersplugin/trunk
python setup.py bdist_egg
cp dist/AutocompleteUsers-0.4.2dev-py2.7.egg /data/trac/domob/plugins
驗證:
插件管理中看到有AutocompleteUsers-0.4.2dev出現
新建一new ticket測試cc中是否會自動完成用戶
 
(3).安裝DateFiled插件
wget http://trac-hacks.org/changeset/latest/datefieldplugin?old_path=/&filename=datefieldplugin&format=zip
unzip datefieldplugin-r12573.zip
cd datefieldplugin/1.0
python setup.py bdist_egg
cp dist/TracDateField-3.0.0dev-py2.7.egg /data/trac/domob/plugins/
 
其它插件相同安裝方法不再一一介紹.
 
Trac升級方法:
1.停止Trac服務
2.更新Trac
如果現在的一些依賴包滿足新版Trac要求,可以用easy_install --upgrade Trac==1.0 直接更新
如果不滿足需要重新安裝
3.更新項目Trac環境
cd /data/trac
cp -r domob domb-old  //更新前最好先備份一下防止發生意外導致無法回滾
trac-admin domob upgrade  //更新trac環境需要很長時間
4.更新文檔
trac-admin domob wiki upgrade
4.重新編譯安裝用到的插件 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章