1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - centos - 正文

君子好学,自强不息!

linux下svn安装和使用(centos)

2023-02-26 | centos | gtxyzz | 6117°c
A+ A-

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

本文来源:1818IP

本文地址:https://www.1818ip.com/post/32858.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。