目录
一、安装Apache2和SVN
二、Apache2设置
三、subversion配置
四、创建仓库和设置权限
五、仓库备份和恢复
系统环境
Ubuntu Linux (20.04) + apache2 + Subversion(1.13.0)
通过命令在线安装apache2和subversion
apt-get install apache2 libapache2-mod-svn subversion
1.修改apache默认端口
我这里有冲突,所以将listen修改成8818。我不需要https访问,所有不需要安装和配置SSL相关。
vim /etc/apache2/ports.conf
2.重启apache
systemctl start apache2
3.查看apache2状态并通过网页访问
systemctl status apache2
1.验证SVN是否安装成功
svn --version
2.创建svn根目录(版本库主目录)
mkdir -p /data/svn
3.svn与apache整合
修改dav_svn配置
vim /etc/apache2/mods-enabled/dav_svn.conf
#/svn表示 http://hostname/svn/myproject
DAV svn
SVNParentPath /data/svn/
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /data/svn/passwd
AuthzSVNAccessFile /data/svn/authz
Require valid-user
验证用户名密码的数据文件 passwd
验证用户的权限配置文件 authz
4.创建密码文件
生成账号(会要求输入2次密码,保存会加密)第一次需要加c,第二次就不要了
htpasswd -c /data/svn/passwd admin
5.创建权限文件
touch /data/svn/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
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[/]
admin = rw
!=
这里 [/] 表示根目录,所有仓库。admin = rw 表示admin账号有读写权限
6.启动SVN服务
svnserve -d -r /data/svn
启动SVN服务器,这里说明下:
-d:表示在后台运行
-r:指定服务器的根目录
停止服务器的命令:killall svnserve
7.查看进程
ps -aux | grep svnserve
1.创建sourcecode仓库
svnadmin create /data/svn/sourcecode
2.修改当前仓库的配置文件
vim /data/svn/sourcecode/conf/svnserve.conf
去掉这几段话之前的#
anon-access = none #关闭匿名访问
auth-access = write #验证用户可写
password-db = passwd #指向验证用户名密码的数据文件 passwd
auth-db=authz #指向验证用户的权限配置文件 authz
3.授权仓库目录权限
chmod -R 777 /data/svn/sourcecode
4.网页访问
http://192.168.31.200:8818/svn/sourcecode/
会弹窗验证密码,验证刚刚的admin账号就行了
5.删除仓库
删除现有的仓库
rm -rf /data/svn/sourcecode
1.备份仓库
将现有仓库导出成dump文件
svnadmin dump /data/svn/sourcecode > sourcecode.dump
2.恢复仓库
先创建空白仓库,再将dump文件恢复到仓库上
cd /data/svn/
svnadmin create sourcecode
svnadmin load /data/svn/sourcecode < /data/svndump/sourcecode.dump