ubuntu系统搭建svn服务器

ubuntu系统搭建svn服务器

SVN是Subversion的简称,是一个开放源代码的版本控制系统,说得简单一点SVN就是用于多个人共同开发同一个项目,共用资源的目的。
如何在ubuntu系统中搭建一个svn服务器呢?

一.环境搭建

1.ubuntu系统更新软件安装包
sudo apt-get update

2.安装svn服务器
sudo apt-get install subversion

3.查看svn 软件版本,可判断是否安装成功
svnserve --version

4.新建仓库目录(选择一个路径,我的路径/opt/svn)
cd /opt/
mkdir svn

5.创建一个代码仓库
sudo svnadmin create /opt/svn/test/
创建完成,其目录下如图
在这里插入图片描述

文件含义
conf存放版本库配置文件
db版本数据存储目录
hooks存放版本库子目录
locks存储库锁目录,用来跟踪库的访问者
format存储一个整数的文件,此整数代表库层次结构版本
readme这个就是一些简介了

6.conf目录,修改svn配置
在这里插入图片描述
svnserve.conf:

### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.  (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.tigris.org/ for more information.

[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",
### and "none".  The sample settings below are the defaults.
anon-access = none     #未鉴权用户拒绝,前面也不能留空格,下同。
auth-access = write     #j鉴权用户可读写
### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd  #用户信息配置文件路径(可以写绝对路径)
### The authz-db option controls the location of the authorization
### rules for path-based access control.  Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file.  If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz     #用户权限配置文件路径(可以写绝对路径)
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
realm = My First Repository  #配置版本库名称

[sasl] #加密
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true   #启用加密
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256

passwd:

### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret  #按照此规则添加用户名和密码
#
admin = 123456

authz:

### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[/]    #用户组权限配置,不可省略,没有配置,会出现authorization failed
admin=rw   #用户权限配置
 

注意如果最后使用svn时报错:authorization failed,注意用户组,用户的权限配置是否完整。

7.启动svn服务
svnserve -d -r /opt/svn/ 注意此目录为svn根目录
ps -ef | grep svnserve
如下图,则启动成功
在这里插入图片描述
注意:这里,我的ubuntu系统没有开启防火墙,此处不需要增加svn端口到防火墙配置中,如果服务器开启防火墙,没有将端口添加进去,连接svn服务器时会出错(计算机拒绝,无法连接)
svn服务器默认使用3690端口,所以开放3690端口,保存设置,然后重启防火墙:
iptables -I INPUT -p tcp --dport 3690 -j ACCEPT
/etc/rc.d/init.d/iptables save
service iptables restart

到此为止,ubuntu svn服务器搭建成功了。

二.测试

1.windows目录下载tortoiseSVN。
下载路径:https://tortoisesvn.net/downloads.html

2.安装
安装成功后,在windows某个路径,建立一个空文件夹
在这里插入图片描述
弹出输入url界面,输入svn服务的路径,本文根据上述创建,输入的url应为:svn://192.168.21.129/test,ip地址ubuntu的ip地址/代码仓库文件夹名,之后弹出用户名密码界面,输入用户名和密码即可完成登录了。

3.上传代码管理
如下图,添加需要管理的代码目录即可。
在这里插入图片描述
注意:笔者操作时报如下图错误
在这里插入图片描述
原因时ubuntu目录代码仓库文件中db文件没有可执行权限
sudo chmod -R 777 db
重新上传代码,成功。
在这里插入图片描述

到此,上面上传的svn代码就可以被多位工程师开发修改,提交,并且记录管理。可以通过控制svn服务的配置添加可以修改代码的用户。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值