Linux下SVN服务器的搭建与配置
一、准备
OS:Linux
二、安装
#cd /usr/local/src/tarbag #tar –xzvf subversion-1.6.6.tar.gz –C ../software/ #cd /usr/local/src/software/subversion-1.6.6 #./configure / --prefix=/usr/local/subversion / //设置安装目录 --with-apr=/usr/local/apache2.2.15 / //指向apr配置文件所在目录,为了和apache同步所以指到这 --with-apr-util=/usr/local/apache2.2.15 / //同上 --with-apxs=/usr/local/apache2.2.15/bin/apxs / --with-ssl / //ssl加密 --with-zlib / --enable-maintainer-mode #make && make install //编译安装
( 如果./configure编译出错: get the sqlite 3.6.13 amalgamation from: http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz unpack the archive using tar/gunzip and copy sqlite3.c from the resulting directory to: This file also ships as part of the subversion-deps distribution. configure: error: Subversion requires SQLite 按照以上提示下载sqlite-amalgamation-3.6.13.tar.gz #cd /usr/local/src/tarbag #wget http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz #tar zxvf sqlite-amalgamation-3.6.13.tar.gz -C ../software # mkdir /usr/local/src/software/subversion-1.6.6/sqlite-amalgamation # cp /usr/local/src/software/sqlite-3.6.13/sqlite3.c /usr/local/software/subversion-1.6.6/sqlite-amalgamation/ #cd /usr/local/src/software/subversion-1.6.6 再次configure,报错如下: configure: maintainer-mode: adding GCC warning flags configure: error: –with-zlib requires an argument. 安装zlib,下载subversion-deps-1.6.6.tar.bz2 #cd /usr/local/src/tarbag #wget http://subversion.tigris.org/downloads/subversion-deps-1.6.6.tar.bz2 #tar jxvf subversion-deps-1.6.6.tar.bz2 -C ../software # cd ../software/subversion-1.6.6/zlib/ # ./configure –shared # make #cd /usr/local/src/software/subversion-1.6.6 再次configure: #./configure / --prefix=/usr/local/subversion / //设置安装目录 --with-apr=/usr/local/apache2 / //指向apr配置文件所在目录,为了和apache同步所以指到这 --with-apr-util=/usr/local/apache2 / //同上 --with-apxs=/usr/local/apache2/bin/apxs / --with-ssl / //ssl加密 --with-zlib--with-zlib=/usr/local/src/software/subversion-1.6.6/zlib/ / //指定刚刚安装的zlib目录 --enable-maintainer-mode # make && make install )三、建库
#mkdir /usr/local/subversion/repos //把所有的库建在repos这个目录中 #/usr/local/subversion/svnadmin create /usr/local/subversion/repos/garden //建garden库四、导入文件到库中
#./svn import /data/garden file://usr/local/subversion/repos/garden –m "注释"五、迁移库(老svn库中的文件倒入新的svn中)--附加
#./svnadmin hotcopy /www/svn/php /usr/local/subversion/repos/php六、apache的相关配置
apache编译时候需要加 "--enable-dav" "--enable-dav-fs" "--enable-dav-lock"这三个选项.
#vi http.conf LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so //这两编译时候会自己添加的 Include conf/extra/httpd-dav.conf //将这行的注释去掉.编辑httpd-dav.conf 文件
<Location /svn/ > //注意svn后面要加 "/" 不然不能显示主目录 Dav svn SVNListParentPath on SVNPathAuthz off SVNParentPath /usr/local/subversion/repos/ //此处配置你的版本库根目录. Options Indexes FollowSymLinks Order Allow,Deny Allow from all AuthType Basic AuthName "Subversion repository" //提示对话框标题 AuthzSVNAccessFile "/usr/local/subversion/conf/authz" //用户权限配置文件 AuthUserFile "/usr/local/subversion/conf/passwd" //访问版本库用户的文件,须用apache 的 htpasswd命令生成 Require valid-user </Location>七、新建svn用户
第一次添加用户需要加上-c参数,以后都不需要参数
# htpasswd -c /usr/local/subversion/conf/passwd八、用户权限分配
# cd /usr/local/subversion/conf # vi authz对用户权限进行分配
[groups] administrator = svnadmin #定义组,一个组内可以包括多个用户 garden = gardenuser,gardenuser1,testuser php = phpuser,phpuser2,phpuser3 # [garden:/] @administrator = rw #administrator 这个组对garden整个库有读写(rw)权限 @garden = rw #这个组也是读写,设定组的话,前面要加上“@”符号。 Phpuser = rw #不带@,表示它为用户,phpuser这个用户对这个库有读写权限 * = r #"*"表示其他任何用户,而且只读 //以下是对garden库下的tip目录的权限配置 [garden:/tip] @administrator = rw @garden = rw * = r //以下是对php这个库做的权限配置 [php:/] @administrator = rw @php = rw * = r九、测试
十、常见错误
1、 服务器发送了意外的返回值(403 Forbidden),在响应 OPTIONS 的请求
检查apache日志/usr/local/apache/logs/error_log.如果出现类似" Failed to load the AuthzSVNAccessFile: An authz rule refers to group '@deployers', which is undefined" 的错误代码。请仔细检查你的authz文件中是否有定义@deployers这个组(group).
十一、库的简单备份.导入
备份: /usr/local/subversion/bin/svnadmin dump /usr/local/subversion/repos/garden/ > /tmp/garden.dump 导入:/usr/local/subversion/bin/svnadmin load /usr/local/subversion/repos/garden/ < /tmp/garden.dump