参考文档:
Ubuntu下安装SVN及配置:https://www.cnblogs.com/oneTOinf/p/7927781.html
SVN服务器在Ubuntu16.04下搭建多版本库详细教程:https://www.cnblogs.com/lovechen/p/5716213.html
一、安装
直接使用命令进行安装
1 | sudo apt-get update |
二、配置
1.在home下创建一个svn文件夹
1 | sudo mkdir /home/svn |
2.创建仓库
1 | sudo mkdir /home/svn/HairRobot |
进入到仓库中使用ls命令查看1
2cd /home/svn/HairRobot
ls
3.为了便于管理,将所有版本库的密码和权限设置在同一个文件下面,操作步骤如下
取出HairRobot下面conf文件夹下的authz和passwd两个文件到svn根目录下面1
2sudo cp /home/svn/HairRobot/conf/authz /home/svn/authz
sudo cp /home/svn/HairRobot/conf/passwd /home/svn/passwd
4.修改HairRobot仓库库目录conf文件夹下面的svnserve.conf文件
1 | cd /home/svn/HairRobot/conf |
password-db = ../../passwd,authz-db = ../../authz
代表相对路径而非绝对路径
5.添加角色(密码数据库)
打开svn目录下的passwd文件,创建方法是在[user]下面添加 username = passwd,记得“=”前后的空格1
2cd /home/svn
sudo vi passwd
6.添加组及分配权限(认证规则库)
1 | cd /home/svn |
[groups] section:为了便于管理,可以将一些用户放到一个组里边,比如:owner=allen,ellen
groups下边的sections表示对一个目录的认证规则,比如对根目录的认证规则的section为[/]。设置单用户的认证规则时一个用户一行1
2
3[/]
whoami = rw # whoami 对根目录的权限为rw
test = r # test 对根目录的权限为r
如果使用group,需要在group名字前加@,如
1 | @owner=rw #group owner中的用户均为rw,等价于上边的两句话 |
启动时如果从/home/svn/HairRobot启动,/就是HairRobot目录,用如上方式以HairRobot目录为根设置权限。
如果从/home/.svn/启动,每个仓库根还是自己的起始目录。可以采用如上方式设置HairRobot的权限,也可以采用如下方式:
*
代表所有人有r(读权限)
1 | [HairRobot:/] |
每个仓库的根目录(/)就是自己的起始目录;[repos:/]这种方式只适用于多仓库的情况;[/]适合于单仓库和单仓库的方式。
7.启动和停止
svnserve -d -r 目录 –listen-port 端口号1
svnserve -d -r /home/svn
访问方式:svn://172.21.24.6/HairRobot
停止服务1
killall svnserve
8.检查
netstat -an | grep 3690
可以检查服务是否启动1
2netstat -an | grep 3690
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN
三、自启动
1.在/etc/init.d目录建立一个脚本文件svnd.sh
1 | cd /etc/init.d |
2.svnd.sh文件中添加如下内容
1 | !/bin/bash |
ubuntu 16.04中一定要加上以下LSB信息,不然放入启动脚本的时候会报错无法开机启动
3.更新修改权限
1 | update-rc.d svnd.sh defaults |