Subversion 支持多种模式,有两种比较常用,一种是默认的SVN访问,3690端口,另一种基于apachewebdav模式80端口,安装配置有所区别

 

SVN模式访问:

1)       可以直接rpm安装

yum -y install subversion

2)        查看是否安装成功

svnserve --version

3)       创建版本库的目录

mkdir -p /var/www/svn/repos

4)        创建版本库repos

svnadmin create /var/www/svn/repos/

5)        以后台方式启动svnserver服务,并指定跟目录

svnserve -d -r /var/www/svn/repos/

 

6)        导入目录mysvn中的文件到版本库,需要-m

svn import mysvn file:///var/www/svn/repos/ -m "Initial import"

7)        导入完成后可查看文件

svn list file:///var/www/svn/repos/

8)        修改版本库中的三个文件

authz 添加用户

[groups]

admin = tony

[/]

@admin = rw

passwd 设置用户密码

[users]

tony = 123456

svnserve.conf 添加以下项目,注意不要有空格

anon-access = none  auth-access = write  password-db = passwd  authz-db = authz

9)        重启svnserver服务

kill -9 `ps auxf |grep svn |grep -v grep|awk '{print $2}'` && svnserve -d -r /var/www/svn/repos

10)    在另外一台服务器上checkout版本库到mysvn目录

svn co --username tony --password 123456 svn://{svn服务器IP}/ mysvn/

11)    基本操作命令

svn update 更新版本库 svn add test.php添加test.php文件

svn status 查看当前状态 svn diff 查看差异 svn commit -m "add test.php"提交修改

 

webdav模式访问

1)        下载apachesubversion安装包

wget http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.19.tar.gz

wget http://subversion.tigris.org/downloads/subversion-1.6.12.tar.gz

wget http://subversion.tigris.org/downloads/subversion-deps-1.6.12.tar.gz

2)        编译安装apachesubversion

tar zxvf httpd-2.2.19.tar.gz

cd httpd-2.2.19

./configure -prefix=/usr/local/apache -enable-dav -enable-so

make && make install

 

tar zxvf subversion-1.6.12.tar.gz

tar zxvf subversion-deps-1.6.12.tar.gz

cd subversion-1.6.12

rm -rf apr && rm -rf apr-util

./configure -prefix=/usr/local/subversion -with-apxs=/usr/local/apache/bin/apxs -with-apr=/usr/local/apache/bin/apr-1-config -with-apr-util=/usr/local/apache/bin/apu-1-config

make && make install

3)       编译过程可能遇到的错误

configure: error: no XML parser was found: expat or libxml 2.x required

执行:yum -y install libxml2 libxml2-devel

yum -y install expat expat-devel

configure:error: We require OpenSSL; try --with-openssl

执行:yum -y install openssl-devel

4)        安装完成后添加环境变量

/etc/profile中添加:export PATH=$PATH:/usr/local/subversion/bin

5)        创建svn版本库部分同上

mkdir -p /var/www/svn/repos

svnadmin create /var/www/svn/repos/

6)        添加apache用户,并修改版本库所有者

useadd apache

chown -R apache:apache /var/www/svn/repos/

7)       设置版本库的权限

chown root:root /var/www/svn

chmod 755 /var/www/svn 

apache SVN目录有执行权限

 

chown apache:apache /var/www/svn/repos

chmod 755 /var/www/svn/repos

apache repos目录要有执行权限

 

chmod -R 766 /var/www/svn/repos/db

apache db目录要有执行权限

其他用户 db目录要有写权限

 

chmod -R 755 /var/www/svn/repos/dav

其他用户 dav目录要有执行权限

 

其他文件只需要读权限即可

8)       配置apache支持svn

更改用户及用户组为apache: apache
User apache
Group apache

vi /usr/local/apache/conf/httpd.conf 添加以下内容

#################################

<Location /svn>

   DAV svn

   SVNPath /var/www/svn/repos

      AuthType Basic

      AuthName "Authorization Realm"

      AuthUserFile /var/www/svn/repos/passwdfile

          AuthzSVNAccessFile /var/www/svn/repos/authz

      Require valid-user

</Location>

####################################

9)       创建版本库中的用户

 

authz 添加用户

[groups]

admin = tony

[/]

@admin = rw

10)   创建版本库中的用户密码文件

/usr/local/apache/bin/htpasswd –cmb passwdfile tony 123456

create   mmd5  b :在命令行上输入密码

解释:创建passwdfile文件,增加用户名为tony的用户,密码为md5加密的123456

更新密码

htpasswd passwdfile abc

添加新用户

htpasswd passwdfile abc

删除用户

htpasswd -D passwdfile abc

11)   启动http服务

/usr/local/apache/bin/httpd –k start

可以在浏览器中输入http:// {svn服务器IP}/svn/或者通过svn客户端工具访问版本库了