centos下面搭建svn服务器详细流程

1.安装svn服务器

先使用svnserve --version命令查看有没有安装svn服务器。

可以看到已经安装了,如果没有安装使用如下命令安装:

yum install -y subversion

2.创建svn版本库

mkdir /home/svn #我这里把版本库放在了home目录下的svn文件夹,方便管理 

svnadmin create /home/svn/repo0 #我这里将svn作为所有版本库的目录,并创建了一个名为repo0的版本库仓库

3.配置这个创建的版本库

进入刚才的创建的这个版本库的conf目录来配置这个repo0的版本库,可以看得到有三个文件

authz: 权限控制,哪些用户可以访问哪些文件

passed: 设置用户和密码的

svnserve.conf: 设置svn相关的操作

2.1先设置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

xiajun=123456
lisi=12

这样我们就建立了xiajun用户, 123456密码,lisi用户,12密码


2.2 再设置权限authz

###  - 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

team0=xiajun
team1=lisi

#xiajun在team0组
#lisi在team1组


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



# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
#
[repo0:/]
@team0=rw
@team1=r
# 第一个小组有读写的权限,第二个小组只有读取的权限



2.3最后设定snvserv.conf

[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 = read   #没有登录用户不能访问
auth-access = write  #登录用户可以写入
### 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  #密码文件为当前目录下的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  #验证权限文件为当前目录下的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 =/home/svn/repo0 #认证命名空间,subversion会在认证提示显示,并且作为凭证缓存的关键字。

[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

采用认配置. 以上语句都必须顶格写,左侧不能留空格,否则会出错.


好了,通过以上配置,你的svn就可以了。

3.启动svn服务器

启动svnserve -d -r /home/svn/repo0

可以看得到该版本库的svn服务器已经启动了。

4. 导入工程(还是在linux下面)

$ mkdir myproject  

$ mkdir myproject/trunk  

$ mkdir myproject/branches  

$ mkdir myproject/tags  

svn import myproject svn://192.168.1.109/repo0/MyProject -m "first import project"

注意一定要导入工程到这个版本库里,repo0只是一个仓库,仓库里面要放项目

5.检出工程

建议在windows下采用TortoiseSVN,连接地址为:svn://yourserveraddress(如果指定端口需要添加端口:端口号)

svn://172.16.81.106/repo0/myproject

可以看得到已经检出了

后面使用svn上传修改删除都可以使用TortoiseSVN操作,比较简单。

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native