开发服务器环境搭建
#!/bin/bash # install python # install subversion # install sqlite # install LAMP yum -y install MySQL-python.i386 mysql.i386 mysql-devel.i386 mysql-server.i386 yum -y install php-xml.i386 php.i386 mod_suphp.i386 php-devel.i386 php-ldap.i386 p-readline.i386 # install optional # install trac # install mantis |
假定仓库的地址为 /work/repos,我们进行如下的操作:
#svnadmin create --fs-type fsfs /work/repos/projectA #svnadmin create --fs-type fsfs /work/repos/projectB |
主要设置 /work/repos/ProjectA/conf/下面的passwd和authz文件,具体如何设置请查看svn的帮助。
subversion有三种运行方式,本地,svnsever,以及同apache整合,我们要使用的是最后一种方式,后面会具体介绍如何配置。
接下来我们要创建trac的环境,假定我们安装到/work/trac-env/目录下,使用如下命令:
#trac-admin /work/trac-env/projectA initenv #trac-admin /work/trac-env/projectB initenv |
我们的主要精力放在了如何把subversion以及trac和apache结合起来,提供一个web管理界面上,所以这部分是我们的重头戏。
如果按照我们上面的脚本的安装方式,在安装完成后,在/etc/httpd/conf.d/目录下面应该有subversion.conf和trac.conf两个文件,我们分别配置他们就行了,二者没有必然的联系。
LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so #上面两行用于家在模块 <Location /repos> DAV svn # SVNPath /work/repos/projectA #如果只显示一个工程,则用这个 SVNParentPath /work/repos #显示所有工程 # 下面进行权限配置 # # Limit write permission to list of valid users. <LimitExcept GET PROPFIND OPTIONS REPORT> # # Require SSL connection for password protection. # # SSLRequireSSL # AuthType Basic AuthName "subversion repository" AuthUserFile /work/repos/.htpasswd #密码文件必须用htpasswd生成 AuthzSVNAccessFile /work/repos/.authz #管理组的权限 Require valid-user </LimitExcept> </Location> |
在配置完成后,重新启动http服务:#apachectl restart
这时候就可以通过命令:svn co http://your_site_ip/repos/projectA
把projectA的源码check到本地了(前提是你有相应权限),如果具有写权限,以后可以直接通过svn commit命令提交修改结果。
配置/etc/httpd/conf.d/trac.conf,下面是给出的一个蓝本
#设定目录权限,如果不设置这个,你会得到没有访问权限的错误,很烦人哟 <Directory "/usr/share/trac/htdocs"> Order allow,deny Allow from all </Directory> #以后你就可以输入 http://your_site/trac来访问,执行的就是这个trac.cgi ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi ### Trac need to know where the database is located <Location "/trac"> # SetEnv TRAC_ENV "/work/trac-env/projectA" #如果只显示一个工程,用这个 SetEnv TRAC_ENV_PARENT_DIR "/work/trac-env" #显示多个工程 </Location> ### You need this to allow users to authenticate <Location "/trac/login"> AuthType Basic AuthName "trac" AuthUserFile /work/trac-env/trac.htpasswd #使用htpasswd生成的密码文件 Require valid-user </location> ScriptAlias /trac/projectA /usr/share/trac/cgi-bin/trac.cgi ### Trac need to know where the database is located <Location "/trac/projectA"> SetEnv TRAC_ENV "/work/trac-env/projectA" #如果只显示一个工程,用这个 # SetEnv TRAC_ENV_PARENT_DIR "/work/trac-env" #显示多个工程 </Location> ### You need this to allow users to authenticate <Location "/trac/project/Alogin"> AuthType Basic AuthName "trac" AuthUserFile /work/trac-env/projectA/trac.htpasswd #使用htpasswd生成的密码文件 Require valid-user </location> ScriptAlias /trac/projectB /usr/share/trac/cgi-bin/trac.cgi ### Trac need to know where the database is located <Location "/trac/projectA"> SetEnv TRAC_ENV "/work/trac-env/projectB" #如果只显示一个工程,用这个 # SetEnv TRAC_ENV_PARENT_DIR "/work/trac-env" #显示多个工程 </Location> ### You need this to allow users to authenticate <Location "/trac/project/Alogin"> AuthType Basic AuthName "trac" AuthUserFile /work/trac-env/projectB/trac.htpasswd #使用htpasswd生成的密码文件 Require valid-user </location> |
至此,我们已经配置完了,现在在浏览器输入 http://your_site_ip/trac/projectA 就能看到一个web界面的管理系统了,好好体验一把喽。
还有一点不是很爽,有时候我们需要只输入IP就能找到我们需要的网页,比如我们输入http://your_site就得到一个页面,而不要http://your_site_ip/trac/projectA才得到。我的做法是建立文件/var/www/html/index.html,并设置其转到对应页。下面是我的一个设置:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Redirection</title> <meta http-equiv="refresh" content="0;URL=/trac/projectA"> </head> <body> <h1><center> edirecting to trac bug system ...<br> <a href="/trac/projectA">哈哈,到这来</a> </h1> </body> </html> |
三、使用简介
这里也给出另外一种选择: svn(cvs)〔版本控制〕 + viewVC〔web界面〕 + mantis〔bug追踪〕,如果可能的话,我会给出这种选择的配置情况。这里有一篇讲述如何在windows下安装viewVC的 http://schnell.blogchina.com/4627119.html , 还有竹笋炒肉的mantis学习笔记http://hedong.3322.org/archives/000263.html
四 viewvc 安装手记
基本步骤如下
wget http://viewvc.tigris.org/files/documents/3330/31766/viewvc-1.0.0.tar.gz这里再给出一个viewvc的配置范例,其中主要设置的地方在 root_parents,default_root 以及有关enscript用于语法高亮的东西
wget http://www.iki.fi/mtr/genscript/enscript-1.6.4.tar.gz
tar -xf enscript-1.6.4.tar.gz
cd enscript-1.6.4
./configure
make && make install
# if success, enscript will install on /usr/local/bin /usr/local/share/enscript
tar xf viewvc-1.0.0.tar.gz
cd viewvc-1.0.0
# just press <enter> for options
read pause
./viewvc-install
# just press <enter> for options
echo 'install viewvc ok'
# after that viewvc will be installed in /usr/local/viewvc-1.0.0
cp /usr/local/viewvc-1.0.0/bin/cgi/viewvc.cgi /var/www/cgi-bin
echo '++++++++++++++++++++++++++++++++++++++++++++++++++'
echo '| configure /usr/local/viewvc-1.0.0/viewvc.conf |'
echo '++++++++++++++++++++++++++++++++++++++++++++++++++'
root_parents = /home/svn-repos: svn,
/home/cvs-repos: cvs
default_root = hypersim
use_rcsparse = 0
address = <div>Administered by: <strong>ASL HyperSim Team</strong> <a href="mailto:[email protected]">lirui</a>
forbidden =
kv_files =
languages = en-us
[options]
root_as_url_component = 0
default_file_view = log
checkout_magic = 0
http_expiration_time = 600
generate_etags = 1
sort_by = file
sort_group_dirs = 1
hide_attic = 1
log_sort = date
diff_format = h
hide_cvsroot = 1
hr_breakable = 1
hr_funout = 0
hr_ignore_white = 1
hr_ignore_keyword_subst = 1
hr_intraline = 0
allow_annotate = 1
allow_markup = 1
allow_compress = 1
template_dir = templates
show_subdir_lastmod = 0
show_logs = 1
show_log_in_markup = 1
cross_copies = 1
use_localtime = 0
py2html_path = .
short_log_len = 80
#setting for syntax highlightning
use_enscript = 1
enscript_path = /usr/loca/bin
# should we add line numbers?
highlight_line_numbers = 1
# convert tabs to ## spaces (use 0 for no conversion)
highlight_convert_tabs = 4
use_php = 0
php_exe_path = php
allow_tar = 0
use_cvsgraph = 0
cvsgraph_path =
cvsgraph_conf = cvsgraph.conf
use_re_search = 0
use_pagesize = 0
limit_changes = 100
[cvsdb]
enabled = 0
其中这些都在各自的领域做的都很好,如果有一个能够把这些工具集大成者,就很好了,有个scmbug好像在做这方面的努力。