首页 > FreeBSD > FreeBSD 10.3 上的构建独立版本SVN服务器
2017
06-11

FreeBSD 10.3 上的构建独立版本SVN服务器

FreeBSD Subversion服务器安装

1、安装Subversion

从ports安装subversion

# cd /usr/ports/devel/subversion
# make install clean

配置如下图

 

2、svn文件的存储位置。 例如 /opt/svn/repos

# mkdir -p /opt/svn/repos

3、创建一个svn用户和组, 用于svnliteserve守护程序运行的用户。

# pw groupadd svn
# pw adduser svn -g svn -s /usr/sbin/nologin

4、设置 /opt/svn/repos 目录权限

# chown -R svn:svn /opt/svn/repos

5、添加svnliteserve 启动脚本

# vi /usr/local/etc/rc.d/svnliteserve

添加以下内容

#!/bin/sh
#
# svnliteserve.sh for rc.d usage (c) 2016 Greg Kennedy.
# $Id$

# PROVIDE: svnliteserve
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable SVNServe:
#
#  svnliteserve_enable="YES"
#  # optional
#  svnliteserve_flags="-d --listen-port=3690 --listen-host 0.0.0.0"
#  svnliteserve_data="/usr/local/repositories"
#  svnliteserve_user="svn"
#  svnliteserve_group="svn"
#
# Note:
# svnliteserve bind per default at the ipv6 address!
# If you want svnliteserve binding at ipv4 address, you have
# to use option 'svnliteserve_flags' with --listen-host parameter

. /etc/rc.subr

# Set some defaults
svnliteserve_enable=${svnliteserve_enable:-"NO"}
svnliteserve_flags=${svnliteserve_flags:-"-d --listen-port=3690 --listen-host 0.                                                                                                                                                             0.0.0"}
svnliteserve_data=${svnliteserve_data:-"/opt/svn/repos"}
svnliteserve_user=${svnliteserve_user:-"svn"}
svnliteserve_group=${svnliteserve_group:-"svn"}

name=svnliteserve
rcvar=svnliteserve_enable
load_rc_config $name
command=/usr/bin/svnliteserve
command_args="-r ${svnliteserve_data}"

run_rc_command "$1"

编辑 /etc/rc.conf 添加以下内容

svnliteserve_enable="YES"

6、启动SVN服务器

# /usr/local/etc/rc.d/svnliteserve start

 

FreeBSD Subversion服务器配置

1、设置存储库

# /usr/bin/svnliteadmin create /opt/svn/repos

 

2、修改/opt/svn/repos/conf/svnserve.conf 如下

[general]
anon-access = none #控制非鉴权用户访问版本库的权限 取值  "write", "read", "none"
auth-access = write #控制鉴权用户访问版本库的权限 取值  "write", "read", "none"
password-db = passwd #指定用户名口令文件名,当前目录 /opt/svn/repos/conf/passwd
authz-db = authz #指定权限配置文件名,当前目录 /opt/svn/repos/conf/authz

3、编辑/opt/svn/repos/conf/passwd 用户密码文件

[users]
user1 = test123 #格式用户名=密码
admin1 = test123
admin2 = test123

 

4、编辑 /opt/svn/repos/conf/authz文件授予用户特定的读写权限

[groups]
admin = admin1,admin2
user = user1

[/]
@admin = rw

[/trunk]
@admin = rw
@user = rw

[/branches]
@admin = rw
@user = rw

[/tag]
@admin = rw
@user = rw

5、重起svnliteserve 加载刚刚修改的文件

# /usr/local/etc/rc.d/svnliteserve restart

 

6、使用 SVN客户端测试一下

svn checkout svn://192.168.1.100

 

参考文献

https://theexplorator.wordpress.com/2014/12/17/setting-up-a-svn-server-on-freebsd/

https://forums.freebsd.org/threads/56745/

最后编辑:
作者:dnybz
这个作者貌似有点懒,什么都没有留下。