1. 简介
--svn(subversion)是近年来崛起的版本管理工具,是cvs的接班人。目前,绝大多数开源软件都使用svn作为代码版本管理软件。
运行方式:svn服务器有2种运行方式:独立服务器和借助apache。
数据存储方式:svn存储版本数据也有2种方式:BDB和FSFS。
因为BDB方式在服务器中断时,有可能锁住数据,所以还是FSFS方式更安全一点。
安全领域:SVN可以满足各种企业VPN的要求,通过为公司内部网络、远程和移动用户、分支机构和合作伙伴提供基于Internet的安全连接。所以,我们可以将SVN看成是VPN、防火墙、基于企业策略的信息管理软件集成在一起的Internet安全的综合解决方案。
2. 详细安装
/*SVN具体参考安装:http://blog.youkuaiyun.com/wooin/archive/2006/07/11/903974.aspx
官方下载:http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=260&expandFolder=74
参考说明书:http://man.chinaunix.net/linux/debian/debian_learning/ch09s14.html*/
1、tar -jxf subversion-1.6.13.tar.bz2
2、配置安装
#./configure --prefix=/usr/local/subversion --with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util --with-sqlite=/usr/local/sqlite \
--with-neon=/usr/local/neon --enable-maintainer-mode
# make && make install
3、错误及处理措施
A、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:
/wins/java/subversion-1.6.13/sqlite-amalgamation/sqlite3.c
This file also ships as part of the subversion-deps distribution.
B、An appropriate version of neon could not be found, so libsvn_ra_neon
will not be built. If you want to build libsvn_ra_neon, please either
install neon 0.29.0 on this system
or
get neon 0.29.0 from:
http://www.webdav.org/neon/neon-0.29.0.tar.gz
unpack the archive using tar/gunzip and rename the resulting
directory from ./neon-0.29.0/ to ./neon/
C、处理措施:
wget http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz
tar -zxvf http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz
cd /usr/local/src/sqlite-3.6.13/
./configure --prefix=/usr/local/sqlite
make && make install
mkdir -p /wins/java/subversion-1.6.13/sqlite-amalgamation
cp sqlite3.c /wins/java/subversion-1.6.13/sqlite-amalgamation
wget http://www.webdav.org/neon/neon-0.29.0.tar.gz
tar -zxvf neon-0.29.0.tar.gz
cd /usr/local/src/neon-0.29.0
./configure --prefix=/usr/local/neon --enable-shared
make && make install
4、SVN创建
# svn --version
--创建库文件所在的目录 (svnroot用户进行下面的操作),任意目录
# mkdir /home/svnroot/repository
--进入subversion的bin目录
# cd /usr/local/subversion/bin
--创建仓库"test"
# ./svnadmin create /home/svnroot/repository/test
# cd /home/svnroot/repository/test
--看看是不是多了些文件,如果是则说明Subversion安装成功了
# ls –l
# cd /usr/local/subversion/bin
--这条语句将把路径/home/user/import下找到的文件导入到你创建的 Subversion 仓库中去,
--提交后的修订版为1。
# ./svn import /home/user/import file:///home/svnroot/repository/test –m "注释"
--不让其他人有该目录的权限
# chmod 700 /home/svnroot/repository
5、修改Apache配置文件
# cd /usr/local/apadche2/bin
//启动Apache
# ./apachect1 start
# vi /usr/local/apache2/conf/httpd.conf
//在最下面添加
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /svn>
DAV svn
SVNParentPath /home/svnroot/repository/ --svn父目录
AuthzSVNAccessFile /home/svnroot/repository/authz.conf --权限配置文件
AuthType Basic --连接类型设置
AuthName "Subversion.zoneyump" --连接框提示
AuthUserFile /home/svnroot/repository/authfile --用户配置文件
Require valid-user --采用何种认证
</Location>
--其中authfile是通过
--"htpasswd [–c] /home/svnroot/repository/authfile username password"
--来创建的
--"Require valid-user"告诉apache在authfile中所有的用户都可以访问。如果没有它,
--则只能第一个用户可以访问新建库
6、整合Apache和SVN
[root@www bin]# apachectl start
httpd: Syntax error on line 54 of /usr/local/apache2/conf/httpd.conf:
Cannot load /usr/local/apache2/modules/mod_dav_svn.so into server: /usr/local/apache2/modules/mod_dav_svn.so:
undefined symbol: dav_register_provider
/*Apache下整合的SVN,由于自己需要加modules,就重新./configure,
make make install后启动apache出现如下错误:
httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf:
Cannot load /usr/local/apache2/modules/mod_dav_svn.so into server:
/usr/local/apache2/modules/mod_dav_svn.so:
undefined symbol: dav_register_provider
*/
解决办法:
重新httpd的./configure 增加参数
./configure --prefix=/usr/local/apache2 -enable-dav --enable-so --enable-modes-shared=most \
--with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ \
--with-pcre=/usr/local/pcre -enable-maintainer-mode -enable-rewrite
make && make install
--and
cp /usr/local/svn/bin/s* /usr/local/apache2/modules
cp /usr/local/svn/bin/s* /usr/local/apache2/bin
ldd mod_dav_svn.so #加载一下配置
/usr/local/apache2/bin/apachel start
7、权限管理
1)增加用户
# /usr/local/apache2/bin/htpasswd -cm /home/svnroot/repository/authfile wooin
--第一次设置用户时使用-c表示新建一个用户文件。回车后输入用户密码
# htpasswd authfile 用户名(加入新的用户)
2)权限分配
# vi /home/svnroot/repository/authz.conf
[test:/] //这表示,仓库test的根目录下的访问权限
wooin = rw //test仓库wooin用户具有读和写权限
bao = r //test仓库bao用户具有读权限
[test2:/] //test2仓库根目录下的访问权限
wooin = r //wooin用户在test2仓库根目录下只有读权限
bao = //bao用户在 test2仓库根目录下无任何权限
[/] //这个表示在所有仓库的根目录下
* = r //这个表示对所有的用户都具有读权限
#[groups] //这个表示群组设置
#svn1-developers = wooin, bao //这个表示某群 组里的成员
#svn2-developers = wooin
#[svn1:/]
#@svn1-developers = rw //如果在前面加上@符号,则表 示这是个群组权限设置
--重启Apache,通过 http://localhost/svn/test 访问
3. 重新部署SVN
在/etc/profile的结尾设置一些svn启动时要做的工作
--/usr/sbin/apachectl start
export SVN_EDITOR=vi
/*重新部署SVN仓库
需要将目前的某个仓库导出,并导入到另一个仓库(可以导入到该仓库的指定目录下)。*/
要用到以下的命令:
--导出所有版本到stn.dump文件中
#svnadmin dump /home/svnroot/sonatina/ > stn.dump
--或者也可以只导出其中一个版本
#svnadmin dump /home/svnroot/sonatina/ --revision 10 > stn.r10.dump
--或者也可以导出多个版本,比如0-10版本
#svnadmin dump /home/svnroot/sonatina/ --revision 0:10 > stn.r0-10.dump
--导入到sonatinab/trunk目录下,如果不指定--parent-dir,则会导入到根目录sonatinab/下
#svnadmin load /home/svnroot/sonatinab/ --parent-dir trunk < stn.r0-10.dump