CentOS 7.2 安装Subversion(SVN)
subversion 简介
-
@H_403_22@
Subversion是一个自由开源的版本控制系统。在Subversion管理下,文件和目录可以超越时空。
Subversion将文件存放在中心版本库里,这个版本库很像一个普通的文件服务器,不同的是,它可以记录每一次文件和目录的修改情况,这样就可以借此将数据恢复到以前的版本,并可以查看数据的更改细节。正因为如此,许多人将版本控制系统当作一种神奇的“时间机器”。
subversion 官网:http://subversion.apache.org/
subversion 安装
-
@H_403_22@
安装subversion
[root@linuxprobe~]#yum-yinstallsubversion11
-
@H_403_22@
创建源仓库,以“/var/svn/repos/project”为例
[root@linuxprobe~]#mkdir-p/var/svn/repos/project
[root@linuxprobe~]#svnadmincreate/var/svn/repos/project
#创建源仓库
svnmkdirfile:///var/svn/repos/project/trunk-m"create"Committedrevision
1.[root@linuxprobe~]#svnmkdirfile:///var/svn/repos/project/branches-m"create"
#创建分支Committedrevision
2.[root@linuxprobe~]#svnmkdirfile:///var/svn/repos/project/tags-m"create"
#创建标签Committedrevision
3.1234567812345678
[root@linuxprobe~]#ll/home/project/total0
-rw-r--r--1rootroot0Nov111:57index.go
-rw-r--r--1rootroot0Nov111:57index.html
-rw-r--r--1rootroot0Nov111:57index.PHP
-rw-r--r--1rootroot0Nov111:58index.py
-rw-r--r--1rootroot0Nov111:58info.PHP
[root@linuxprobe~]#svnimport/home/projectfile:///var/svn/repos/project/trunk-m
"initialimport"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
Committedrevision
4.#确认[root@linuxprobe~]#svnlistfile:///var/svn/repos/project/trunkindex.goindex.html
index.PHPindex.py
info.PHP123456789101112131415161718192021123456789101112131415161718192021
-
@H_403_22@
启动svnserver,svnserve监听TCP 3690,防火墙开启端口通信
#svnserver端[root@linuxprobe~]#systemctlstartsvnserve
#svnclient端
[root@vdevops~]#yum-yinstallsvn
[root@vdevops~]#svnlistsvn://linuxprobe.org/repos/projectbranches/tags/
trunk/#导出代码到本地
[root@vdevops~]#svncheckoutsvn://linuxprobe.org/repos/project
Aproject/tags
Aproject/trunk
Aproject/trunk/info.PHP
Aproject/trunk/index.html
Aproject/trunk/index.go
Aproject/trunk/index.PHP
Aproject/trunk/index.py
Aproject/branches
Checkedoutrevision4.1234567891011121314151617181912345678910111213141516171819
-
@H_403_22@
如果没有启动svnserve,通过端口无法连接到svn server,可以通过ssh的方式连接到svn server
#svnserver端[root@linuxprobe~]#systemctlstopsvnserve
#svnclient端[root@vdevops~]
#svnlistsvn+ssh://root@linuxprobe.org/var/svn/repos/projectroot@linuxprobe.org'spassword:
branches/
tags/
trunk/1234567812345678
subversion 访问控制
-
@H_403_22@
设置访问控制“/var/svn/repos/project”
[root@linuxprobe~]#vi/var/svn/repos/project/conf/svnserve.conf
#line9:add(prohibitanonymousaccess)[general]
anon-access=none
#line28:uncommentpassword-db=passwd#line35:uncommentauthz-db=authz
[root@linuxprobe~]#vi/var/svn/repos/project/conf/passwd
#defineusernameandpasswordforthisrepository
[users]
shaon=password
wang=password
devops=password
[root@linuxprobe~]#vi/var/svn/repos/project/conf/authz
#definegroupsandusers
[groups]
developer=devops,wang#allowread/writeondocumentrootfordevelopergroup[/]
@developer=rw#allowreadontrunkfolderforfedorauser
[/trunk]
shaon=r123456789101112131415161718192021222324123456789101112131415161718192021222324
-
@H_403_22@
svn client 客户端测试
[root@vdevopstrunk]#svn--usernameshaonlistsvn://linuxprobe.org/
repos/project/trunkAuthenticationrealm:<svn://linuxprobe.org:3690>
LinuxProbeRepositoryPasswordfor'shaon':
-----------------------------------------------------------------------
ATTENTION!Yourpasswordforauthenticationrealm:
<svn://linuxprobe.org:3690>LinuxProbeRepository
#仓库名称canonlybestoredtodiskunencrypted!Youareadvisedtoconfigure
yoursystemsothatSubversioncanstorepasswordsencrypted,ifpossible.Seethedocumentationfordetails.
Youcanavoidfutureappearancesofthiswarningbysettingthevalueofthe'store-plaintext-passwords'optiontoeither'yes'or'no'in'/root/.subversion/servers'.
-----------------------------------------------------------------------
Storepasswordunencrypted(yes/no)?yes#记住密码index.goindex.htmlindex.PHPindex.py
info.PHP12345678910111213141516171819202122231234567891011121314151617181920212223
Subversion : Windows 客户端
-
@H_403_22@
在window10下安装TortoiseSVN ,TortoiseSVN 下载地址:http://tortoisesvn.net/downloads.html
安装TortoiseSVN后,移动到一个工作文件夹,点击右键,选择“SVN Checkout”,指定存储库的URL,然后单击“确定”
图片描述" title="" style="border:none;height:auto;">
如果在存储库上设置访问控制,则需要进行身份验证,如下所示,继续使用有效的用户和密码。图片描述" title="" style="border:none;height:auto;">
完成结帐后,单击确定按钮图片描述" title="" style="border:none;height:auto;">
只是完成从存储库检出。它可以从这个应用程序操作存储库
Subversion HTTP Access
-
@H_403_22@
安装httpd参考:http://www.jb51.cc/article/p-pukuckix-qq.html
@H_403_22@安装依赖包
[root@linuxprobe~]#yum-yinstallmod_dav_svn11
-
@H_403_22@
为HTTP访问配置Subversion,例如,为存储库“/var/svn/repos/project”
[root@linuxproberun]#vi/etc/httpd/conf.d/subversion.conf#createnew<Location/project>
DAVsvn
AuthTypeBasic
AuthName"DAVSVN"
AuthUserFile/var/svn/.svnpasswd
Requirevalid-user
SVNPath/var/svn/repos/project
</Location>
[root@linuxproberun]#htpasswd-c/var/svn/.svnpasswdwangNewpassword:
Re-typenewpassword:
Addingpasswordforuserwang
[root@linuxproberun]#chown-Rapache./var/svn/repos[root@linuxproberun]#systemctlrestarthttpd[root@linuxproberun]#systemctlstatushttpd12345678910111213141516171234567891011121314151617
-
@H_403_22@
配置访问控制
[root@linuxprobe~]#vi/var/svn/repos/project/conf/authzsvn.conf#definegroup
[groups]
developer=wang,devops
operator=shaon#everyonecanReadaccess[/]
*=r#onlydevelopergroupcanRead/Writeunderthetrunk[project:/trunk]@developer=rw#onlyoperatorcanRead/Writeunderthebranches[project:/branches]@operator=rw#onlyoperatorcanRead/Writeunderthetags[project:/tags]@operator=rw
[root@linuxprobe~]#vi/etc/httpd/conf.d/subversion.conf<Location/project>
DAVsvn
AuthTypeBasic
AuthName"DAVSVN"
AuthUserFile/var/svn/.svnpasswd
Requirevalid-user
SVNPath/var/svn/repos/project
AuthzSVNAccessFile/var/svn/repos/project/conf/authzsvn.conf
</Location>
[root@linuxprobe~]#systemctlrestarthttpd123456789101112131415161718192021222324252627282930123456789101112131415161718192021222324252627282930
-
@H_403_22@
从客户端访问如下
[root@vdevops~]#svn--usernamewanglisthttp://linuxprobe.org/projectAuthenticationrealm:原文链接:https://www.f2er.com/centos/377261.html
<http://linuxprobe.org:80>DAVSVNPasswordfor'wang':
-----------------------------------------------------------------------
ATTENTION!Yourpasswordforauthenticationrealm:
<http://linuxprobe.org:80>DAVSVNcanonlybestoredtodiskunencrypted!Youareadvisedtoconfigure
yoursystemsothatSubversioncanstorepasswordsencrypted,ifpossible.Seethedocumentationfordetails.
Youcanavoidfutureappearancesofthiswarningbysettingthevalueofthe'store-plaintext-passwords'optiontoeither'yes'or'no'in'/root/.subversion/servers'.
-----------------------------------------------------------------------
Storepasswordunencrypted(yes/no)?no
branches/
tags/
trunk/123456789101112131415161718192021123456789101112131415161718192021