一般情况下,Linux都是自带SVN环境的。
查看svn是否安装了
[14:50:28][root@VM60 ~]# rpm -aq subversion
[14:50:30]subversion-1.6.11-9.el6_4.x86_64
[14:52:01][root@VM60 ~]# whereis svn
[14:52:01]svn: /usr/bin/svn /usr/share/man/man1/svn.1.gz
[14:55:59][root@VM60 ~]# svnserve --version
[14:55:59]svnserve, version 1.6.11 (r934486)
[14:55:59] compiled Apr 2 2013, 08:56:54
创建存放代码的svn文件夹
[15:21:34][root@VM60 opt]# mkdir -p svn/data
[15:21:53][root@VM60 opt]# mkdir -p svn/svnpasswd
启动svnserve
[15:22:15][root@VM60 opt]# svnserve -d -r svn/data/
查看是否启动成功
[15:23:33][root@VM60 opt]# ps -ef|grep svn|grep -v grep
[15:23:33]root 24891 1 0 07:19 ? 00:00:00 svnserve -d -r svn/data/
[16:25:14][root@VM60 ~]# netstat -lnt|grep 3690
[16:25:14]tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN
创建项目库
[15:27:03][root@VM60 opt]# svnadmin create svn/data/qualityMonitor
[15:27:13][root@VM60 ~]# cd /opt/svn/data/
[15:27:14][root@VM60 data]# ll
[15:27:14]total 4
[15:27:14]drwxr-xr-x 6 root root 4096 Nov 17 07:24 qualityMonitor
[15:27:16][root@VM60 data]# cd qualityMonitor/
[15:27:17][root@VM60 qualityMonitor]# ll
[15:27:17]total 24
[15:27:17]drwxr-xr-x 2 root root 4096 Nov 17 07:24 conf
[15:27:17]drwxr-sr-x 6 root root 4096 Nov 17 07:24 db
[15:27:17]-r--r--r-- 1 root root 2 Nov 17 07:24 format
[15:27:17]drwxr-xr-x 2 root root 4096 Nov 17 07:24 hooks
[15:27:17]drwxr-xr-x 2 root root 4096 Nov 17 07:24 locks
[15:27:17]-rw-r--r-- 1 root root 229 Nov 17 07:24 README.txt
[15:27:42][root@VM60 qualityMonitor]# cd conf/
[15:27:42][root@VM60 conf]# ll
[15:27:42]total 12
[15:27:42]-rw-r--r-- 1 root root 1080 Nov 17 07:24 authz
[15:27:42]-rw-r--r-- 1 root root 309 Nov 17 07:24 passwd
[15:27:42]-rw-r--r-- 1 root root 2279 Nov 17 07:24 svnserve.conf
编辑配置文件
[15:31:27][root@VM60 conf]# vi 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
### 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 =/opt/svn/svnpasswd/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 =/opt/svn/svnpasswd/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
[15:45:55][root@VM60 conf]# cp authz passwd /opt/svn/svnpasswd
[15:54:57][root@VM60 conf]# cd /opt/svn/svnpasswd/
修改掉权限,安全措施
[15:46:04][root@VM60 svnpasswd]# chmod 700 *
[15:46:06][root@VM60 svnpasswd]# ll
[15:46:06]total 8
[15:46:06]-rwx------ 1 root root 1080 Nov 17 07:43 authz
[15:46:06]-rwx------ 1 root root 309 Nov 17 07:43 passwd
配置用户名密码
[15:46:45][root@VM60 svnpasswd]# vi 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下面添加用户名密码
[users]
# harry = harryssecret
# sally = sallyssecret
liwen.xu=liwen.xu
ting.chen=ting.chen
erhuan.deng=erhuan.deng
miaogen.zeng=miaogen.zeng
配置项目用户权限
[15:50:07][root@VM60 svnpasswd]# vi 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
dev=liwen.xu,ting.chen,erhuan.deng,miaogen.zeng
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
设置项目用户权限。格式必须这样写。
[qualityMonitor:/]
@dev=rw
重启SVNserve
[15:57:43][root@VM60 opt]# pkill svnserve
[15:57:57][root@VM60 opt]# svnserve -d -r svn/data/
[16:25:14][root@VM60 ~]# netstat -lnt|grep 3690
[16:25:14]tcp 0 0 0.0.0.0:3690 0.0.0.0:*
如果修改了 passwd和authz 文件不需要重启,修改了svnserve.conf 必须重启才能生效。
在Linux防火墙中添加3690端口可以通过。
先查看防火墙是否开着,如果关闭的,就不用配置了
service iptables status
编辑/etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 3690 -j ACCEPT
保存在前面部分
再重启:
service iptables restart