CentOS 7.2 安装Subversion(SVN)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 7.2 安装Subversion(SVN)相关的知识,希望对你有一定的参考价值。
CentOS 7.2 安装Subversion(SVN)
subversion 简介
Subversion是一个自由开源的版本控制系统。在Subversion管理下,文件和目录可以超越时空。
Subversion将文件存放在中心版本库里,这个版本库很像一个普通的文件服务器,不同的是,它可以记录每一次文件和目录的修改情况,这样就可以借此将数据恢复到以前的版本,并可以查看数据的更改细节。正因为如此,许多人将版本控制系统当作一种神奇的“时间机器”。subversion 官网:http://subversion.apache.org/
subversion 安装
安装subversion
[[email protected]~]# yum -y install subversion 11
创建源仓库,以“/var/svn/repos/project”为例
[[email protected] ~]# mkdir -p /var/svn/repos/project
[[email protected] ~]# svnadmin create /var/svn/repos/project # 创建源仓库
[[email protected] ~]# svn mkdir file:///var/svn/repos/project/trunk -m "create" Committed revision 1.[[email protected] ~]# svn mkdir file:///var/svn/repos/project/branches -m "create" # 创建分支Committed revision 2.[[email protected] ~]# svn mkdir file:///var/svn/repos/project/tags -m "create" # 创建标签 Committed revision 3.1234567812345678
导入已存在的代码文件到SVN仓库,导入/home/project目录的文件
[[email protected] ~]# 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
[[email protected] ~]# 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.# 确认[[email protected] ~]# svn list file:///var/svn/repos/project/trunkindex.goindex.htmlindex.phpindex.py
info.php123456789101112131415161718192021123456789101112131415161718192021
启动svnserver,svnserve监听TCP 3690,防火墙开启端口通信
# svn server 端[[email protected] ~]# systemctl start svnserve# svn client 端[[email protected] ~]# yum -y install svn[[email protected] ~]# svn list svn://linuxprobe.org/repos/projectbranches/
tags/
trunk/# 导出代码到本地[[email protected] ~]# svn checkout svn://linuxprobe.org/repos/projectA 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.1234567891011121314151617181912345678910111213141516171819
如果没有启动svnserve,通过端口无法连接到svn server,可以通过ssh的方式连接到svn server
# svn server 端[[email protected] ~]# systemctl stop svnserve# svn client端[[email protected] ~]# svn list svn+ssh://[email protected]/var/svn/repos/[email protected]‘s password:
branches/
tags/
trunk/1234567812345678
subversion 访问控制
设置访问控制“/var/svn/repos/project”
[[email protected] ~]# vi /var/svn/repos/project/conf/svnserve.conf# line 9: add (prohibit anonymous access)[general]
anon-access = none# line 28: uncommentpassword-db = passwd# line 35: uncommentauthz-db = authz
[[email protected] ~]# vi /var/svn/repos/project/conf/passwd# define username and password for this repository[users]
shaon= password
wang = password
devops = password
[[email protected] ~]# 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 123456789101112131415161718192021222324123456789101112131415161718192021222324
svn client 客户端测试
[[email protected] trunk]# svn --username shaon list svn://linuxprobe.org/repos/project/trunkAuthentication realm: <svn://linuxprobe.org:3690> LinuxProbe RepositoryPassword 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, ifpossible. See the documentation for details.
You can avoid future appearances of this warning by setting the valueof the ‘store-plaintext-passwords‘ option to either ‘yes‘ or ‘no‘ in‘/root/.subversion/servers‘.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes #记住密码index.goindex.htmlindex.phpindex.py
info.php12345678910111213141516171819202122231234567891011121314151617181920212223
Subversion : Windows 客户端
在window10下安装TortoiseSVN ,TortoiseSVN 下载地址:http://tortoisesvn.net/downloads.html
安装TortoiseSVN后,移动到一个工作文件夹,点击右键,选择“SVN Checkout”,指定存储库的URL,然后单击“确定”
如果在存储库上设置访问控制,则需要进行身份验证,如下所示,继续使用有效的用户和密码。
完成结帐后,单击确定按钮
只是完成从存储库检出。它可以从这个应用程序操作存储库
Subversion HTTP Access
安装httpd参考:http://blog.csdn.net/wh211212/article/details/52982917
安装依赖包
[[email protected]~]# yum -y install mod_dav_svn 11
为HTTP访问配置Subversion,例如,为存储库“/var/svn/repos/project”
[[email protected] 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>
[[email protected] run]# htpasswd -c /var/svn/.svnpasswd wangNew password:
Re-type new password:
Adding password for user wang
[[email protected] run]# chown -R apache. /var/svn/repos [[email protected] run]# systemctl restart httpd [[email protected] run]# systemctl status httpd12345678910111213141516171234567891011121314151617
配置访问控制
[[email protected] ~]# 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
[[email protected]~]# 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>
[[email protected] ~]# systemctl restart httpd 123456789101112131415161718192021222324252627282930123456789101112131415161718192021222324252627282930
从客户端访问如下
[[email protected] ~]# svn --username wang list http://linuxprobe.org/projectAuthentication realm: <http://linuxprobe.org:80> DAV SVNPassword for ‘wang‘:
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
<http://linuxprobe.org:80> DAV SVNcan only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, ifpossible. See the documentation for details.
You can avoid future appearances of this warning by setting the valueof the ‘store-plaintext-passwords‘ option to either ‘yes‘ or ‘no‘ in‘/root/.subversion/servers‘.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? no
branches/
tags/
trunk/123456789101112131415161718192021123456789101112131415161718192021
可以使用Web浏览读取访问
可以使用TortoiseSVN客户端指定我们设置的URL,如下所示
本文出自 “李世龙” 博客,谢绝转载!
以上是关于CentOS 7.2 安装Subversion(SVN)的主要内容,如果未能解决你的问题,请参考以下文章
Citrix XenDesktop发布Centos 7.2桌面--安装Centos7