linux下svn安装和使用(centos)

1.安装svn

本地测试环境 centos6.5

# yum安装	
yum -y install subversion
# 查看svn版本   
svnserve --version
# 建立版本库目录
mkdir /var/svnrepos
# 启动svn服务
svnserve -d -r /var/svnrepos
# 查看进程	
ps -ef |grep svnserve
	root     29215     1  0 10:16 ?        00:00:00 svnserve -d -r /var/svnrepos

2.建立版本库

创建一个新的Subversion项目

svnadmin create /var/svnrepos/test

配置用户访问

cd /var/svnrepos/test/conf
vi svnserve.conf
# 去掉前面注释    
anon-access=none
auth-access=write
password-db=passwd

添加认证用户

vi passwd
# 在[users]下面添加用户和密码 
[users]
username1=password
test=123456

3.客户端测试连接

svn co svn://ip/test
# 用户名:test  密码:123456

如果提示无法连接,请检查iptabales 端口是否开放

vi /etc/sysconfig/iptables
# 添加新开放端口
-A INPUT -p tcp -m tcp --dport 3690 -j ACCEPT
# 重启iptables
service iptables restart #centos6 
systemctl restart iptables.service #centos7

4.实现SVN与WEB同步(hook回调svn update)

假设WEB服务器根目录为/home/wwwroot/web

# checkout一份SVN
svn co svn://localhost/test /home/wwwroot/web

#修改权限为WEB用户
chown -R www:www /var/www/webroot/njlrxx

# 配置hook
cd /var/svnrepos/test/hooks/
cp post-commit.tmpl post-commit
vi post-commit

钩子的内容 start

#!/bin/sh

REPOS="$1"
REV="$2"

BASEPATH=/home/wwwroot/web
WEBPATH="$BASEPATH/"
export LANG=zh_CN.UTF-8
svn update $WEBPATH --username test --password 123456 --no-auth-cache

钩子的内容 end

chmod +x post-commit

最后操作是重启svn服务

# svn服务的
killall svnserve
# svn开启
svnserve -d -r /var/svnrepos

5.相关下载:

svn64位 客户端下载 <br />
链接:http://pan.baidu.com/s/1pLpRKZT 密码:kxj3
原文地址:https://www.cnblogs.com/sentangle/p/11526171.html