LINUX下svn的搭建(yum)

SVN服务器端地址:192.168.122.9


1.Server 端配置
安装【安装 httpd 是因为客户端连接的时候采用了 http 协议】
#yum install subversion httpd -y
建立 SVN 数据储存文件
#mkdir -p /home/svnroot/repository/
建立正式的 SVN 版本库:
#svnadmin create /home/svnroot/repository/test
尝试传几个文件过去【-m 后面照】:
#touch /mnt/file{1,2,3,4}
【这行千万别复制】
#svn import /mnt/ file:///home/svnroot/repository/test –m "注释"
因为要用 http 发布,所以要修改下权限:
#chown -R apache.apache /home/svnroot/
现在开始配置 apache
先安装 svn 支持模块【安装完后会在 conf.d 里面有一个 subversion.conf 的配置文件】
#yum install mod_dav_svn.x86_64 -y
编写 http.conf
#vim /etc/httpd/conf/httpd.conf
...
<Location /svn>
DAV svn  
SVNParentPath /home/svnroot/repository/ #svn访问http://ip/svn 跳转到/opt/svn
AuthzSVNAccessFile /home/svnroot/repository/test/conf/authz
AuthType Basic
AuthName "Subversion.zoneyump"   #显示在登录框的信息
AuthUserFile /etc/httpd/authfile  #存放用户和密码的文件
Require valid-user
</Location>
...
之后建立 httpd 登录用户
#htpasswd -c /etc/httpd/authfile centrald  添加第一个用户使用-c,添加第二个用户使用-m或不加参数

#htpasswd -c /etc/httpd/authfile djhllpf123  添加第一个用户使用-c,添加第二个用户使用-m或不加参数

之后输入密码后就可以在 web 界面登录时使用了。

添加 SVN 用户
#vim /home/svnroot/repository/test/conf/authz
...
[test:/]
* = rw
...
【解释:所有客户端使用 http://server_hostname.example.com/svn/test 这个路径
如果:
http://server_hostname.example.com/svn/python 这个路径就只有 centrald 可写
http://server_hostname.example.com/svn/linux_c 这个路径就只有 djhllpf123可写
[python:/]
centrald= rw
djhllpf123 = r
[linux_c:/]
centrald= r
djhllpf123 = rw

#vim /home/svnroot/repository/test/conf/passwd
...
[users]
# harry = harryssecret
# sally = sallyssecret
在这个文件中设置的用户名与密码无效
...
启动 httpd
#/etc/init.d/httpd start
现在应该可以通过 web 界面去访问 svn 了
网址:http://192.168.122.9/svn/test/
2.客户端配置
Linux 客户端就需要安装 SVN:
#yum install subversion httpd -y
下载服务端的资料:
#svn checkout http://192.168.122.9/svn/test
【之后输入的用户名和密码都是你的 httpd 的用户就是上面的 AuthUserFile /etc/httpd/authfile 里
面的用户】
【如果你在两个认证文件里面都写有验证内容的话,只有两个文件里面信息相同的用户才可以
登录。如:authfile 里面:centrald 密码为 centrald 里面必须有 centrald = rw 这时候才能用 centrald登
陆】
上传本地文件
# svn import /mnt/test.py http://192.168.122.9/svn/test/filename -m '0.0'

3.让svn与php同步使用

svn co http://192.168.122.9/svn/test   /var/www/html/   

第一个目录为svn代码库目录。第二个目录为web目录。
然后再执行:
svn update /var/www/html/ --username svn_name --password svn_passwd --no-auth-cache
测试通过:

然后在svn目录hooks里写上执行脚本:
文件名:post-commit
文件内容:
#!/bin/sh
REPOS="$1"
REV="$2"

export LANG=en_US.UTF-8

svn update /var/www/html/ --username svn_name --password svn_passwd --no-auth-cache

最后不要忘记给web目录写权限和post-commit文件执行权限。

chmod +x post-commit

问题报错与解决

svn提交失败“can't open file /db/txn....”

解决办法:给目录添加读写权限

chmod -R o+rw /home/svnroot/repository/php/

最后再重新启动svn

killall svnserve    #停止
svnserve -d -r /opt/svn/repositories  #启动


转载于:https://my.oschina.net/CentralD/blog/368746

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值