CentOS 5 上配置 Trac 和 Subversion
这是一篇很久以前做项目的时候写的笔记,以前很多笔记都是记在一个一个 txt 里或者干脆不记用到了就去 google 搜,现在有了一个记笔记的好地方:),嗯,就是这个博客。关于 trac 和 subversion 的介绍可以 google 一大堆出来,这里就不赘述了,个人认为 trac 和 subversion 非常适合小型团队或者创业小公司用来管理源代码,追踪 bug,trac 还集成了一个 wiki,可以用来管理文档,发布网页,功能很强大,全 web based 的。很多 open source 项目以及一些欧美小公司都是用 trac + subversin 这个组合来管理项目的。这里有个问题,为什么装了 lighttpd 后还需要 apache 呢? 原因是 lighttpd 现在还没有 svn-dav 模块,只有 apache 有,所以如果要集成 subversion 的话还需要 apache 的支持,当然只配置 apache 来同时处理 web 和 svn 也是可以的。不过这里用 lighttpd 来处理 web,apache 的 svn-dav module 来处理 svn 部分。
安装必要的软件包
首先下载并且安装必要的软件包
yum install mysql mysql-server MySQL-python
yum install subversion
yum install httpd mod_dav_svn
rpm -ivh lighttpd-1.4.13-3.fc5.i386.rpm lighttpd-fastcgi-1.4.13-3.fc5.i386.rpm
rpm -ivh clearsilver-0.10.4-2.el5.rf.i386.rpm
rpm -ivh python-clearsilver-0.10.4-2.el5.rf.i386.rpm
tar zxvf trac-0.10.4.tar.gz; cd trac-0.10.4; python ./setup.py install
配置 MySQL启动 MySQL 并设置 root 密码
/sbin/chkconfig mysqld on
/etc/init.d/mysqld start
mysqladmin -u root password yourrootsqlpassword
mysql -u root -p禁止 MySQL 远程登录,取消注释 “skip-networking”
vi /etc/my.cnf
"skip-networking"删除 MySQL 里面不用的数据库和用户
cp /usr/share/doc/mysql-server-5.0.22/my-huge.cnf /etc/my.cnf
mysql> drop database test;
mysql> use mysql;
mysql> delete from db;
mysql> delete from user where not (host="localhost" and user="root");
mysql> flush privileges;配置 Trac创建一个 trac 需要的数据库
mysql> create database trac character set utf8 collate utf8_general_ci;
mysql> grant usage on trac.* to bang@localhost identified by 'bangpassword';
mysql> grant all on trac.* to bang@localhost identified by 'bangpassword';
mysql -u bang -p
mysql> show databases;创建一个 trac 应用
trac-admin /srv/trac initenv
project name: YourProjectName
db connection string: mysql://bang:bangpassword@localhost:3306/trac
repository type: svn
path to repository: /srv/svn
Configure login and permission
htpasswd -c /srv/tracusers bang设置 trac 的权限
trac-admin /srv/trac permission remove anonymous WIKI_CREATE
trac-admin /srv/trac permission remove anonymous WIKI_MODIFY
trac-admin /srv/trac permission remove anonymous TICKET_MODIFY
trac-admin /srv/trac permission add bang WIKI_CREATE WIKI_MODIFY
trac-admin /srv/trac permission add bang TICKET_CREATE TICKET_MODIFY
trac-admin /srv/trac permission add bang REPORT_CREATE REPORT_MODIFY
trac-admin /srv/trac permission add bang REPORT_CREATE REPORT_MODIFY配置 Lighttpd 和 Apache在 Lighttpd 的配置文件中打开一些需要的模块
vi /etc/lighttpd/lighttpd.conf
mod_rewrite, mod_access, mod_auth, mod_proxy, mod_fastcgi, mod_accesslog选择 htpasswd 的认证方式
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/srv/tracusers"
auth.require = ( "/trac/login" =>
( "method"=> "basic",
"realm" => "YourProjectName Project",
"require" => "valid-user"
)
)设置 lighttpd 并利用 mod_proxy 模块转发请求到 apache 的8080端口
proxy.server = ( "/svn/simba" =>
(("host" => "127.0.0.1", "port" => 8080))
)
fastcgi.server= ( "/trac" =>
( "trac" =>
("socket" => "/tmp/trac-fastcgi.socket",
"bin-path" => "/usr/share/trac/cgi-bin/trac.fcgi",
"check-local" => "disable",
"bin-environment" =>
( "TRAC_ENV" => "/srv/trac" )
)
)
)
配置 Apache 载入 svn 等模块
htpasswd -cm /srv/svnusers bang
vi /etc/httpd/conf/httpd.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
...
Listen 8080
...
< VirtualHost *:8080 >
ServerName YourServerName
DocumentRoot /srv/www/lighttpd
< Location /svn/simba >
DAV svn
SVNPath /srv/svn
AuthType Basic
AuthName "Subversion Respository"
AuthUserFile /srv/svnusers
AuthzSVNAccessFile /srv/svnaccess
SVNPathAuthz off
Require valid-user
< /Location >
< /VirtualHost >
vi /srv/svnaccess
* = r
bang = rw注释掉 apache 的一些不用模块
vi /etc/httpd/conf/httpd.conf
ServerTokens ProductOnly
Timeout 60
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
#LoadModule include_module modules/mod_include.so
#LoadModule status_module modules/mod_status.so
#LoadModule info_module modules/mod_info.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule cgi_module modules/mod_cgi.so配置 Subversion创建以下目录
mkdir tmpsvn
mkdir tmpsvn/simba
mkdir tmpsvn/simba/branches (keep track of major forks in the code)
mkdir tmpsvn/simba/tags (snapshots of an entire source tree are here)
mkdir tmpsvn/simba/trunk (your first imported source code tree)创建 svn 并且导入源代码
svnadmin create /srv/svn
svn import tmpsvn/ file:///srv/svn -m "Initial import"修改 trac 时需要的文件
vi /srv/trac/conf/trac.ini
vi /srv/trac/templates/site_footer.cs
vi /srv/trac/templates/site_header.cs
vi /usr/share/trac/templates/header.cs
vi /usr/share/trac/templates/wiki.cs
vi /usr/share/trac/templates/footer.cs
vi /usr/share/trac/htdocs/css/trac.cs在 trac 代码中删除 “about and help/guide, search” 导航
vi /usr/lib/python2.4/site-packages/trac/web/chrome.py (close to the bottom)
items.sort(navcmp)
-----------------------------------------
# remove navigation items, see trac:#4191
itemsdup = list(items)
for name,label in itemsdup:
if ('-' + name) in order:
items.remove((name,label))
-----------------------------------------
for name, text in items:删除trac wiki里一些不必要的导航
vi /srv/trac/conf/trac.ini
mainnav = wiki,-timeline,-roadmap,browser,-tickets,-newticket,search
metanav = login,logout,-settings,-help,-about数据备份最后提一下备份,备份 mysql, trac 和 subversion
mysqldump -u bang -p trac > sb_sql_20070601
trac-admin /srv/trac hotcopy ./sb_trac-20070601
tar cvf sb_trac-20070601.tar sb_trac-20070601
gzip sb_trac-20070601.tar.gz
svnadmin dump /srv/svn > sb_svn-20070601
转载自:VPSEE
页:
[1]