Centos7配置svn

1、安装
yum install subversion
2、测试安装是否成功:
[root@192 log]# svnserve --version
3、建立版本库
[root@192 log]# mkdir /var/svn
4、创建版本库:
[root@192 log]# svnadmin create /var/svn/pro
如果删除版本库
rm -rf /var/svn/somnus
5、配置svn配置文件
[root@192 log]# cd /var/svn/pro
[root@192 svn]# cd conf
[root@192 svn]# vi /var/svn/pro/conf/svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
只需要修改上面的四个配置,其它不变                  


6、编辑svn用户配置文件
[root@192 conf]# vi /var/svn/pro/conf/passwd
[users]
admin = admin                #用户,密码
fuhd = fuhd                #用户,密码
test = test                #用户,密码


7、编辑svn权限控制配置文件
[root@192 conf]# vi /var/svn/pro/conf/authz
[groups]
admin = admin         #admin为用户组,等号之后的admin为用户
test = fuhd,test


[somnus:/]                #表示根目录(/var/svn/pro)
@admin = rw            #表示admin组对根目录有读写权限,r为读,w为写


[somnus:/test]         #表示test目录(/var/svn/pro/test)
@test = rw                #表示test组对test目录有读写权限


8、启动,查看和停止SVN服务
启动SVN服务:
# -d : 守护进程  -r : svn数据根目录 
$ svnserve -dr /var/svn            #用root权限启动


重启
killall svnserve && svnserve -dr /var/svn/pro


查看SVN服务:
$ ps aux|grep svnserve               #默认端口为:3690
9、配置防火墙端口
首先要明确CentOS7的默认防火墙为firewallD。subversion的默认端口为3690,如果没有打开会报错:


$ firewall-cmd --permanent -add-port=3690/tcp
$ firewall-cmd --reload
10、检索项目和切换项目的url
$ svn checkout svn://192.168.0.112/XK_Project .     #使用 checkout  服务器资源 本地目录
切换项目url
$ svn switch --relocate svn://192.168.0.112/XK_Project svn://192.168.0.120/XK_Project   # 使用 switch 迁移 from  to 新的地址
11、设置开机启动
在centos7, 设置开机启动:
$ systemctl enable svnserve.service      #注意:根目录必须是/var/svn 这样才能设置成功!!
#设置开机启动后就可以按下面的方式开启或停止服务了
$ systemctl start svnserve.service
$ systemctl stop svnserve.service


12、关闭SELinux
setenforce 0
永久关闭
vim /etc/sysconfig/selinux
SELINUX = disable               #值修改为disable.










-------------------------------------------------------------------------------------
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.apache.org/ for more information.


[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete 
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = none #修改
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 #修改
### 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
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above.  Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
#force-username-case = none


[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
zhangsan = 123456 #用户名=密码
lisi = 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
admin=zhangsan


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


# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r


[/] #根目录

@admin=rw #为组设置读写权限



参考资料

http://blog.csdn.net/u012486840/article/details/52524389














你可能感兴趣的:(Centos7配置svn)