专栏首页运维前线CentOS 7.2 安装Subversion(SVN)

CentOS 7.2 安装Subversion(SVN)

版权声明:本文为木偶人shaon原创文章,转载请注明原文地址,非常感谢。 https://blog.csdn.net/wh211212/article/details/53128805

subversion 简介

  • Subversion是一个自由开源的版本控制系统。在Subversion管理下,文件和目录可以超越时空。 Subversion将文件存放在中心版本库里,这个版本库很像一个普通的文件服务器,不同的是,它可以记录每一次文件和目录的修改情况,这样就可以借此将数据恢复到以前的版本,并可以查看数据的更改细节。正因为如此,许多人将版本控制系统当作一种神奇的“时间机器”。
  • subversion 官网:http://subversion.apache.org/

subversion 安装

  • 安装subversion
[root@linuxprobe~]# yum -y install subversion 
  • 创建源仓库,以“/var/svn/repos/project”为例
[root@linuxprobe ~]# mkdir -p /var/svn/repos/project
[root@linuxprobe ~]# svnadmin create /var/svn/repos/project   # 创建源仓库
[root@linuxprobe ~]# svn mkdir file:///var/svn/repos/project/trunk -m "create" 
Committed revision 1.
[root@linuxprobe ~]# svn mkdir file:///var/svn/repos/project/branches -m "create" # 创建分支
Committed revision 2.
[root@linuxprobe ~]# svn mkdir file:///var/svn/repos/project/tags -m "create" # 创建标签 
Committed revision 3.
  • 导入已存在的代码文件到SVN仓库,导入/home/project目录的文件
[root@linuxprobe ~]# ll /home/project/
total 0
-rw-r--r-- 1 root root 0 Nov  1 11:57 index.go
-rw-r--r-- 1 root root 0 Nov  1 11:57 index.html
-rw-r--r-- 1 root root 0 Nov  1 11:57 index.php
-rw-r--r-- 1 root root 0 Nov  1 11:58 index.py
-rw-r--r-- 1 root root 0 Nov  1 11:58 info.php
[root@linuxprobe ~]# svn import /home/project file:///var/svn/repos/project/trunk -m "initial import"
Adding         /home/project/index.html
Adding         /home/project/index.go
Adding         /home/project/index.php
Adding         /home/project/index.py
Adding         /home/project/info.php
Committed revision 4.
# 确认
[root@linuxprobe ~]# svn list file:///var/svn/repos/project/trunk
index.go
index.html
index.php
index.py
info.php
  • 启动svnserver,svnserve监听TCP 3690,防火墙开启端口通信
# svn server 端
[root@linuxprobe ~]# systemctl start svnserve
# svn client 端
[root@vdevops ~]# yum -y install svn
[root@vdevops ~]# svn list svn://linuxprobe.org/repos/project
branches/
tags/
trunk/
# 导出代码到本地
[root@vdevops ~]# svn checkout svn://linuxprobe.org/repos/project
A    project/tags
A    project/trunk
A    project/trunk/info.php
A    project/trunk/index.html
A    project/trunk/index.go
A    project/trunk/index.php
A    project/trunk/index.py
A    project/branches
Checked out revision 4.
  • 如果没有启动svnserve,通过端口无法连接到svn server,可以通过ssh的方式连接到svn server
# svn server 端
[root@linuxprobe ~]# systemctl stop svnserve
# svn client端
[root@vdevops ~]# svn list svn+ssh://root@linuxprobe.org/var/svn/repos/project
root@linuxprobe.org's password: 
branches/
tags/
trunk/

subversion 访问控制

  • 设置访问控制“/var/svn/repos/project”
[root@linuxprobe ~]# vi /var/svn/repos/project/conf/svnserve.conf
# line 9: add (prohibit anonymous access)
[general]
anon-access = none
# line 28: uncomment
password-db = passwd
# line 35: uncomment
authz-db = authz
[root@linuxprobe ~]# vi /var/svn/repos/project/conf/passwd
# define username and password for this repository
[users]
shaon= password
wang = password
devops = password
[root@linuxprobe ~]# vi /var/svn/repos/project/conf/authz
# define groups and users
[groups]
developer = devops,wang
# allow read/write on document root for developer group
[/]
@developer = rw
# allow read on trunk folder for fedora user
[/trunk]
shaon = r 
  • svn client 客户端测试
[root@vdevops trunk]# svn --username shaon list svn://linuxprobe.org/repos/project/trunk
Authentication realm: <svn://linuxprobe.org:3690> LinuxProbe Repository
Password for 'shaon': 

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <svn://linuxprobe.org:3690> LinuxProbe Repository  # 仓库名称

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes #记住密码
index.go
index.html
index.php
index.py
info.php

Subversion : Windows 客户端

安装TortoiseSVN后,移动到一个工作文件夹,点击右键,选择“SVN Checkout”,指定存储库的URL,然后单击“确定”

如果在存储库上设置访问控制,则需要进行身份验证,如下所示,继续使用有效的用户和密码。

完成结帐后,单击确定按钮

只是完成从存储库检出。它可以从这个应用程序操作存储库

Subversion HTTP Access

[root@linuxprobe~]# yum -y install mod_dav_svn 
  • 为HTTP访问配置Subversion,例如,为存储库“/var/svn/repos/project”
[root@linuxprobe run]#  vi /etc/httpd/conf.d/subversion.conf
# create new
<Location /project>
    DAV svn
    AuthType Basic
    AuthName "DAV SVN"
    AuthUserFile /var/svn/.svnpasswd
    Require valid-user
    SVNPath /var/svn/repos/project
</Location> 
[root@linuxprobe run]# htpasswd -c /var/svn/.svnpasswd wang
New password: 
Re-type new password: 
Adding password for user wang
[root@linuxprobe run]# chown -R apache. /var/svn/repos 
[root@linuxprobe run]# systemctl restart httpd 
[root@linuxprobe run]# systemctl status httpd
  • 配置访问控制
[root@linuxprobe ~]# vi /var/svn/repos/project/conf/authzsvn.conf 
# define group
[groups]
developer = wang,devops
operator = shaon
# everyone can Read access
[/]
* = r
# only developer group can Read/Write under the trunk
[project:/trunk]
@developer = rw
# only operator can Read/Write under the branches

[project:/branches]
@operator = rw
# only operator can Read/Write under the tags

[project:/tags]
@operator = rw
[root@linuxprobe~]# vi /etc/httpd/conf.d/subversion.conf
<Location /project>
    DAV svn
    AuthType Basic
    AuthName "DAV SVN"
    AuthUserFile /var/svn/.svnpasswd
    Require valid-user
    SVNPath /var/svn/repos/project
    AuthzSVNAccessFile /var/svn/repos/project/conf/authzsvn.conf
</Location> 
[root@linuxprobe ~]# systemctl restart httpd 
  • 从客户端访问如下
[root@vdevops ~]# svn --username wang list http://linuxprobe.org/project
Authentication realm: <http://linuxprobe.org:80> DAV SVN
Password for 'wang': 

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <http://linuxprobe.org:80> DAV SVN

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? no
branches/
tags/
trunk/
  • 可以使用Web浏览读取访问
  • 可以使用TortoiseSVN客户端指定我们设置的URL,如下所示

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • CentOS7安装使用svn

    版权声明:本文为木偶人shaon原创文章,转载请注明原文地址,非常感谢。 https://b...

    shaonbean
  • CentOS 7.2 安装MariaDB

    版权声明:本文为木偶人shaon原创文章,转载请注明原文地址,非常感谢。 https://blog...

    shaonbean
  • CentOS 7 安全加固、检测、审计

    版权声明:本文为木偶人shaon原创文章,转载请注明原文地址,非常感谢。 https://blog...

    shaonbean
  • 数字在排序数组中出现的次数

    题目:统计一个数字在排序数组中出现的次数。例如输入排序数组{1,2,3,3,3,3,4,5}和数字3,由于3在这个数组中出现了4次,因此输出4. 找到排序数组中...

    猿人谷
  • Histogram of Oriented Gridients(HOG) 方向梯度直方图

    作者 张旭 编辑 徐松 1. HOG简介 2. 数字图像梯度定义 3. HOG基本步骤 4. OpenCV实现HOG 5. 用KNN与HOG实现一个手写数字输...

    机器学习算法工程师
  • Kubernetes Scheduler的Predicates和Priorities Policies解读

    本文是对Kubernetes V1.5 Scheduler 的预选策略Predicates Policies和优选策略Priorities Policies的含...

    Walton
  • day5(面向对象2)

    ##Runtime对象 该类并没有提供构造函数。说明不可以new 对象,那么会直接想到该类中的方法都是静态的,发现该类中海油非静态方法。 说明该类肯定会提供了方...

    小二三不乌
  • Python中SSH协议的实现 - Pa

    操作系统维护时, 一般会通过ssh命令连接到远端服务器, 进行某些操作. 那Python中如何完成这些呢, 当然也能执行ssh命令, 但还有更优雅的方式, 借助...

    用户2398817
  • Httpd运维日志:通过apxs添加模块

    Brief                                   在部署Httpd时为方便管理和安全等原因,我们仅会安装所需的模块,那么后期功能扩...

    ^_^肥仔John
  • [2013.11.13][cpp]检测机器大端或者小端

    ApacheCN_飞龙

扫码关注云+社区

领取腾讯云代金券