ubuntu 搭建 svn 服务器

安装 subversion

sudo apt-get remove --purge subversion

sudo apt-get update
sudo apt-get install subversion

创建 SVN 用户

sudo adduser svn
sudo adduser svn sudo
sudo su svn

创建仓库目录

sudo mkdir /svn
sudo mkdir /svn/repos
sudo mkdir /svn/repos/public
sudo chmod 777 -R /svn/repos/public
sudo chown svn:svn -R /svn

创建版本库

sudo svnadmin create /svn/repos/public

$ ls -lah /svn/repos/public
total 32K
drwxrwxrwx 6 svn  svn  4.0K 6月  19 14:15 .
drwxr-xr-x 3 svn  svn  4.0K 6月  19 14:15 ..
drwxr-xr-x 2 root root 4.0K 6月  19 14:15 conf
drwxr-sr-x 6 root root 4.0K 6月  19 14:15 db
-r--r--r-- 1 root root    2 6月  19 14:15 format
drwxr-xr-x 2 root root 4.0K 6月  19 14:15 hooks
drwxr-xr-x 2 root root 4.0K 6月  19 14:15 locks
-rw-r--r-- 1 root root  246 6月  19 14:15 README.txt
cd /svn/repos/public
sudo chmod -R 777 db
cd conf
sudo cp svnserve.conf svnserve.conf.bak
sudo vim svnserve.conf

取消注释:

$ sudo diff -u svnserve.conf svnserve.conf.bak 
--- svnserve.conf       2023-06-19 13:27:33.473464875 +0800
+++ svnserve.conf.bak   2023-06-19 13:26:30.071350251 +0800
@@ -16,15 +16,15 @@
 ### The sample settings below are the defaults and specify that anonymous
 ### users have read-only access to the repository, while authenticated
 ### users have read and write access to the repository.
-anon-access = read
-auth-access = write
+# anon-access = read
+# 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
+# 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
@@ -33,7 +33,7 @@
 ### file in a Subversion repository.  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
+# authz-db = authz
 ### The groups-db option controls the location of the file with the
 ### group definitions and allows maintaining groups separately from the
 ### authorization rules.  The groups-db file is of the same format as the

说明:(去掉前面的#,并且顶格)

  • anon-access = none 匿名用户不可读
  • auth-access = write 权限用户可写
  • password-db = passwd 密码文件为 passwd
  • authz-db = authz 权限文件为 authz

修改 passwd

sudo cp passwd passwd.bak
sudo vim passwd
$ cat /svn/repos/public/conf/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]
hanmeimei = iampassword
lilei = helloworld

新增用户格式:名字 = 密码

修改 authz

sudo cp authz authz.bak
sudo vim authz
$ cat /svn/repos/public/conf/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]
students = hanmeimei,lilei
# 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
[public:/]
@students = rw
* =

启动服务

sudo su svn
sudo svnserve -d -r /svn --listen-port 81

下载安装 windows 小乌龟

https://tortoisesvn.net/downloads.zh.html

访问 svn 服务器

  • svn://10.0.0.:81/public