CentOS 7 安装SVN 添加多版本库

1.安装SVN:
      yum install subversion
2.查看svn版本号:
      svnserve --version
3.创建版本库:
建目录:
      mkdir /data/svn
//================================================
建版本库1:
      svnadmin create /data/svn/default
建版本库2:
      svnadmin create /data/svn/default2

4.配置版本库(添加用户和配置权限,以下配置均需顶格写,否则出错):
//版本库1配置:
      vi /data/svn/default/conf/authz
##############################
[default:/]
centos = rw #用户 centos具有读写权限
##############################

     vi /data/svn/default/conf/passwd

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

[users]
centos = 123456 #用户centos

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

     vi /data/svn/default/conf/svnserve.conf

##############################
anon-access = none  #匿名用户访问权限,无
auth-access = write     #普通用户访问权限,读 写
password-db = passwd        #用户密码文件
authz-db = authz        #权限配置文件
realm = /data/svn/default    #版本库所在目录

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

 

//版本库2配置:
      vi /data/svn/default2/conf/authz
##############################
[default2:/]
centos = rw #用户 centos具有读写权限
##############################

     vi /data/svn/default2/conf/passwd

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

[users]
centos = 123456 #用户centos

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

     vi /data/svn/default2/conf/svnserve.conf

##############################
anon-access = none  #匿名用户访问权限,无
auth-access = write     #普通用户访问权限,读 写
password-db = passwd        #用户密码文件
authz-db = authz        #权限配置文件
realm = /data/svn/default2    #版本库所在目录

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

5.启动svn服务:
     svnserve -d -r /data/svn/
如果报错则需要关闭进程并重新启动
     ps aux | grep svn
     kill -9 14268

     svnserve -d -r /data/svn/

 

7.防火墙放开3396端口允许外部访问:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3690 -j ACCEPT

 

8.测试,在linux WEB目录下 checkout:

[root@localhost conf]# cd /www/
[root@localhost www]# svn checkout svn://localhost/default  www
Authentication realm: /data/svn/default
Password for 'root':
Authentication realm: /data/svn/default
Username: centos
Password for 'centos':
Store password unencrypted (yes/no)? y
Skipped '.'
Summary of conflicts:
 Skipped paths: 1
[root@localhost www]# touch 1.php
[root@localhost www]# svn add 1.php
A         1.php
[root@localhost www]# svn commit -m "add" 1.php
Adding         1.php
Transmitting file data .
Committed revision 2.
[root@localhost www]#

 

============其他操作===========

cd /www/wwwroot/default/www 更新版本

svn update 更新版本

svn cleanup 解除锁定

rm -rf ~/.subversion/auth 忘记账号

============================

 

9.用6的方法checkout 版本库2

 

10. PC上测试 checkout是否正常:

windows 下载  TortoiseSVN=》


D:/www/default/目录下,右键SVN checkout=》

URL填写:svn://xxxxx.com/default=》

点击OK,填写账号centos/123456

确定后 开始更新线上版本库文件

11.用同样方法 在D:\www\default2\目录下checkout 版本库2


12.加钩子,实现 有新提交时,站点目录自动更新版本:

//添加新web目录作为开发测试站点
/www/wwwroot/default_test/www (Apache需要添加对应子站点,子域名需要解析过来)

//添加用户
[root@localhost hooks]# useradd -u 1000 webserver -d /www/wwwroot/

[root@localhost hooks]# passwd webserver
Changing password for user webserver.
New password:
Retype new password:

passwd: all authentication tokens updated successfully.

//添加文件post-commit
[root@localhost hooks]# vim post-commit

//文件post-commit中加入以下脚本

#!/bin/sh
export LANG=zh_CN.UTF-8
SVN=/usr/bin/svn
WEB=/www/wwwroot/default_test/www
$SVN update $WEB --username webserver --password ******

//赋权限

[root@localhost hooks]# chown webserver post-commit
[root@localhost hooks]# chmod 755 post-commit

//版本库conf/authz,conf/passwd文件中添加账号

webserver / ******

//关闭svn进程,重新开启

svnserve -d -r /data/svn

//切换到测试站点目录

cd /www/wwwroot/default_test/

//用账号 webserver / ******  检出

svn checkout svn://localhost/default  www

//PC端提交新文件后,若测试站点目录下是否已出现新添加的文件就OK了

ls /www/wwwroot/default_test/www

CentOS 7 中安装 Subversion (SVN) 需要几个步骤,因为默认仓管理工具不是 SVN。以下是详细的安装过程: 1. **更新包列表并安装依赖**: ``` sudo yum update -y sudo yum install -y curl-devel expat-devel gettext-devel openssl-devel apr-util-devel apr-devel ``` 2. **下载并配置 Apache HTTP Server** (用于作为 SVN 服务器的前端): ``` sudo yum install httpd mod_dav_svn -y ``` 启动并设置为开机启动: ``` sudo systemctl start httpd sudo systemctl enable httpd ``` 3. **安装 SVN**: ``` sudo yum install subversion -y ``` 4. **配置 SVN**: 打开 SVN 的配置文件 `httpd.conf` 或者找到 `conf.d/subversion.conf` (取决于你的 Apache 版本),通常位于 `/etc/httpd/conf.d/` 目录下。添加以下内容,如果不存在则需要手动创建: ```bash LoadModule dav_svn_module /usr/lib64/httpd/modules/mod_dav_svn.so <Location /repos> DAV svn SVNParentPath /path/to/repositories AuthType Basic AuthName "Subversion Repositories" AuthUserFile /path/to/svn-auth-file </Location> ``` 其中 `/path/to/repositories` 是 SVN 存储的实际路径,`/path/to/svn-auth-file` 是存放用户名和密码的文件。 5. **设置 SVN 用户权限**: 创建一个 SVN 用户组和文件权限: ``` sudo useradd -R svn-user:svn-user /path/to/repositories sudo chmod -R g+rwx,o= /path/to/repositories ``` 6. **配置 SVN 认证文件**: 使用 `htpasswd` 工具创建认证文件,例如 `/path/to/svn-auth-file`: ``` sudo htpasswd -c /path/to/svn-auth-file username ``` 按提示输入新用户的密码。 7. **重启 Apache** 服务以应用更改: ``` sudo systemctl restart httpd ``` 现在你应该可以访问 `http://your-server-ip/repos` 来使用 SVN 了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

one312

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值