FreeBSD搭建SVN服务器

我最喜欢使用的OS就是FreeBSD,而且现在刚好有一台FreeBSD服务器,所以我想把我的SVN服务器迁移到FreeBSD上,再配合hudson和ant就可以自动编译了。

第一步:安装svn:

在安装它之前先使用命令pkg_delete -f libtool*  把libtool里的东西去掉让它自动更新到最新的,否则安装时会出错的。

使用ports安装:

cd /usr/ports/devel/subversion/

#make install WITHOUT_BDB=yes WITH_MOD_DAV_SVN=yes APXS=/usr/local/sbin/apxs
说明:WITHOUT_BDB=yes 这是不使用BerkleyDB才加上的,你愿意使用可以去掉,WITH_MOD_DAV_SVN=yes APXS=/usr/local/sbin/apxs 两个参数是为了支持Apache的WebDAV方式
如果不使用apache的话就可以把对它的支持选项全部去掉。
第二步:建库:
mkdir /usr/svn         #把它做为svn的要目录
svnadmin create /usr/svn/projectOne      #projectOne就是建的第一个库
第三步:配置权限:
在projectOne下的conf文件夹下有一个conf文件夹,要修改它下面的三个文件:
1、增加一个用户,打开passwd文件,加入一个用户名与密码:如
[users]
# harry = harryssecret
# sally = sallyssecret
test = test   #这里加入一个test用户,并且密码是test
2、修改用户权限:
打开authz文件,配置如下:(只要修改groups节点)
[groups]
admin = test     #这里表示有一个admin用户组,这个用户组中用一个叫test的用户
[/]               #这里是特别需要注意,如果启动时是指定的svn的要目录就用/,比如启动是指定的是
                 #svnserve -r -d /usr/svn/,        如果启动时指定的是 -r -d /usr/svn/projectOne   这里就要     用 [/projectOne]b 
@admin = rw           #表示admin组中的用户都有读写权限
* = r
# [repository:/baz/fuz]
3、修改svnserver.conf文件,配置如下:
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                 #指写权限分配文件
第三步:启动svn服务:
svn默认启动的是IPV6的,所以在启动时需要加一些参数:
svnserve -d -r /usr/svn/ --listen-host=0.0.0.0 --listen-port=3690
这样就可以了。

好了,开始使用吧,先建立数据库文件存放位置。我这里建立/usr/local/svn_data文件夹,然后输入:

  svnadmin create /usr/local/svn_data .
编辑/etc/inetd.conf文件,在后面追加:
   svn stream tcp nowait root /usr/local/bin/svnserve sveserve -i
编辑/etc/rc.conf,增加:
   inetd_enable="YES"
重新启动后,这样服务就会自动启动了。可以用netstat -an检查3690端口是否启动。
  
 
每个数据库的权限的管理:
  打开/usr/local/svn_data/conf文件夹
 编辑snvserve.conf, 去掉下列#号:
 [general]
 non-access = read    // 非认证用户允许读
 auth-access = write  // 认证用户允许写
 password-db = passwd // 密码记录文件
  authz-db = authz     // 权限认证文件
 realm = svn_data     // 区域标志,随便填
添加用户,编辑passwd:
  去掉[users]前#号,添加用户如: 
  [users]
   admin = 123
   user1 = a
权限设置,编辑authz,去掉[groups]前#号,设置如下:
  [groups]
   Manage = admin        // 管理组
  user = user1          // 用户组
 
  [/]                   // 根目录权限
  @Manage = rw          // 管理组权限
  @user = r             // 用户组权限
  * = r                 // 其他用户权限
 
  [/text]
   @Manage = rw
   @user = rw
   * = r
   ...
 
  绿色字体部分不要写入配置里,只供说明!!
 
  客户端我用的是windows,所以装TortoiseSVN,用Visual Studio的话装Ankh插件。
先介绍这么多吧,后面的我还要继续摸索。
原文地址:https://www.cnblogs.com/Alight/p/3241041.html