一、trac 概念
Trac 是用Python写的一个基于Web的事件跟踪系统,它使用WiKi作为文档的格式,Subversion作为版本控制系统。可帮助开发人员进行源码版
本管理、Bug跟踪和讨论。Debian
如果你的系统是Debian则用apt-get install trac命令安装即可,Trac依赖的所有软件包系统会自动安装。安装完成后,就可进行配置了。
Trac可以设置成Standalone服务器,只供本机使用。也可以与Apache等Web服务器集成,如果与Apache集成,则可配置成CGI、FastCGI或
Mod_Python等方式 。
本人文采用:
redhat 9
apache 2 (mod_python)
mysql 5 (mysql_python)
Subversion 1.4
trac 0.10.4
二、trac 官网安装方法
http://trac.edgewall.org/wiki/TracInstall
它所依赖的包:
*Python, version >= 2.3 //Please keep in mind, that for RPM-based systems you will also need python-devel and python-
xml packages.
*ClearSilver, version >= 0.9.3 //With python-bindings (./configure --with-python=/usr/bin/python)
*A web server capable of executing CGI/FastCGI scripts, or Apache HTTPD with mod_python.
* Subversion, version >= 1.0. (>= 1.1.x recommended)
* Subversion SWIG Python bindings (not PySVN).
*必须的数据库支持(SQLite,PostgreSQL,MySQL(0.10.4以上版本的trac完全支持).
在安装之前要先确认这些包是否满足trac 的要求。
我的就是RH9 版本太低了,结果依赖的包超多。
三、各个包的安装方法:
1、python:
# tar xjvf Python-2.5.tar.gx
# cd Python-2.5
# ./configure --with-apxs=/usr/local/apache/sbin/apxs
# make;make install
2、clearsilver:
如果报此错就说明clearsilver没有安装好 TracError: ClearSilver not installed (No module named neo_cgi)
# tar xfz clearsilver-0.10.5.tar.gz
# cd clearsilver-0.10.5
# ./configure --disable-apache --disable-csharp --disable-ruby --prefix=/usr --with-python=/usr/local/bin/python
#sed -i "[email protected]/usr/local/bin/[email protected]/usr/bin/env
[[email protected]][email protected][/email]
" scripts/document.py
#make || return 1
#make install
#cd python
#PYTHON_SITE=`/usr/local/bin/python -c \
"import sys; print [path for path in sys.path if path.find(‘site-packages‘) != -1][0]"`
# python setup.py install
3、mysql_python:
# tar xfz MySQL-python-1.2.1.tar.gz
# cd MySQL-python-1.2.1
# python setup.py build
# python setup.py install
在安装mysql_python之前一定要装好mysql_client
如果提示无法找到mysql_config
vi site.cfg
#mysql_config = /usr/local/bin/mysql_config
去掉注释,改为你mysql_config 所在的路径
4、mod_python:
# tar zxvf mod_python-3.3.1.tar.gz
# cd mod_python-3.3.1
# ./configure --with-apxs=/usr/local/apache/sbin/apxs
# make
# make install
在apache配置文件里加入模块
vi /usr/local/apache2/conf/httpd.conf
LoadModule python_module modules/mod_python.so
四、创建数据库:
# cd /usr/local/mysql
# mysqladmin create dbname
# mysql -uroot -p
> passwd
> grant all privileges on dbname.* to
[[email protected]][email protected][/email]
identified by ‘dbpass‘;
> use dbname;
> ALTER DATABASE DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
> quit
以本机为例:
# mysqladmin create trac
# mysql -uroot -p
> root(mysql-root 密码)
> grant all privileges on trac.* to
[[email protected]][email protected][/email]
identified by ‘trac‘;
> use trac;
> ALTER DATABASE DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
> quit
注:一定要记住这里创建的数据库名(trac),用户名(trac),密码(trac),主机名(localhost)
因为之后创建trac表的时候需要用到
五、trac的安装及初始化
# tar zxvf trac-0.10.4.tar.gz
# cd trac-0.10.4
# python ./setup.py install
如此处报错请检查以上安装是否有误。
trac初始化:
# trac-admin /usr/local/trac initenv (/usr/loca/trac 目录会自动创建)
Project Name [My Project]> test
Database connection string [sqlite:db/trac.db]> mysql://trac:[email protected]/trac //前面创建数据库所用的到信息
Repository type [svn]> //这里为空,直接回车
Path to repository [/path/to/repos]> /usr/local/apache2/svnroot/test //SVN仓库地址
Templates directory [/usr/local/share/trac/templates]> //这里为空,直接回车,事先请确认这个路径
如果以上配置都正确的话,这步是不会报错的,那么trac 就已经正常安装了。
剩下的只是apache的配置了。
六、配置 trac虚拟主机并启动
# vi /usr/local/apache2/conf/httpd.conf
在未尾加入 :
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /usr/local/trac //trac 安装目录
SetEnv PYTHON_EGG_CACHE /tmp
PythonOption TracUriRoot /trac
AuthType Basic
AuthName "test‘s trac"
AuthUserFile /usr/local/apache2/svnroot/test/passwd //SVN用户密码目录
Require valid-user
重启apache # service httpd restart
http://ip/trac
就可以看到trac界面啦。。
七、总结
其实trac安装并不难,我昨天配置nagios花了一天,并添加了N多插件,今天配了一天的trac其中遇到了N多错误,由于太多了,我也没有
截下图了,所以对错误就不一列举了。其实所有的错误在官文FAQ里都可以找到,并解决。没有什么太难的,多细心,相信你也能配置成功。
明天继续研究trac的其它功能,只用一个太浪费了。并安装bugzilla与trac的BUG跟踪做比较。
trac的一些修改及错误:
trac-email
修改trac.ini
[notification]
always_notify_owner = true
always_notify_reporter = yes
always_notify_updater = true
mime_encoding = quoted-printable
smtp_always_bcc =
smtp_always_cc = @example.com
smtp_default_domain =
smtp_enabled = true
smtp_from = @example.com
smtp_password =
smtp_port = 25
smtp_replyto =
smtp_server =
smtp_user =
use_public_cc = false
use_short_addr = false
use_tls = false
添加附件的时候报错
Python Traceback
Traceback (most recent call last):
File "/usr/local/lib/python2.5/site-packages/trac/web/main.py", line 406, in dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.5/site-packages/trac/web/main.py", line 237, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/local/lib/python2.5/site-packages/trac/attachment.py", line 361, in process_request
self._do_save(req, attachment)
File "/usr/local/lib/python2.5/site-packages/trac/attachment.py", line 496, in _do_save
attachment.insert(filename, upload.file, size)
File "/usr/local/lib/python2.5/site-packages/trac/attachment.py", line 180, in insert
os.makedirs(self.path)
File "/usr/local/lib/python2.5/os.py", line 165, in makedirs
makedirs(head, mode)
File "/usr/local/lib/python2.5/os.py", line 172, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: ‘/usr/local/trac/attachments/ticket‘
解决办法:attachments 目录权限不对。
chmod -R 755 /usr/local/trac/attachments
chown -R XXX.XXXX /usr/local/trac/attachments
修改下拉框---这个下拉框是new ticket 的时候cc 直接可以下拉用户名 而不用手动输入
修改trac.ini
[ticket]
restrict_owner = false改为:true
补:如果报错:TracError: Unsupported version control system "svn". Check that the Python bindings for "svn" are correctly installed.
那就是httpd.conf 里少添加了: SetEnv PYTHON_EGG_CACHE /tmp
更多精彩linux视频教程,尽在51CTO学院:
http://edu.51cto.com/course/courseList/id-48.html