Subversion 支持多种模式,有两种比较经常使用,一种是默认的SVN访问,3690端口,另外一种基于apache的webdav模式80端口,安装配置有所区别php
SVN模式访问:web
1) 能够直接rpm安装apache
yum -y install subversion浏览器
2) 查看是否安装成功服务器
svnserve --versionide
3) 建立版本库的目录svn
mkdir -p /var/www/svn/repos 工具
4) 建立版本库reposui
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) 下载apache和subversion安装包
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) 编译安装apache和subversion
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>
####################################
authz 添加用户
[groups]
admin = tony
[/]
@admin = rw
10) 建立版本库中的用户密码文件
/usr/local/apache/bin/htpasswd –cmb passwdfile tony 123456
c :create m:md5 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客户端工具访问版本库了