目录
安装
安装svn
root@ubuntu:~# apt-get update
root@ubuntu:~# apt-get install subversion
检查是否安装成功
root@ubuntu:~# svn --version
svn, version 1.9.3 (r1718519)
compiled Jul 26 2019, 15:51:17 on x86_64-pc-linux-gnu
Copyright (C) 2015 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository access (RA) modules are available:
* ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
- using serf 1.3.8 (compiled with 1.3.8)
- handles 'http' scheme
- handles 'https' scheme
The following authentication credential caches are available:
* Plaintext cache in /root/.subversion
* Gnome Keyring
* GPG-Agent
* KWallet (KDE)
配置
创建版本仓库
# 新建目录,用于存放代码仓库
root@ubuntu:~# mkdir /data/svn
# 设置权限
root@ubuntu:/data/svn# chmod -R 777 /data/svn
# 创建svn仓库
svnadmin create /usr/svn/repository
# 创建完成后生成如下目录和文件
root@ubuntu:/data/svn# svnadmin create /data/svn/repository
root@ubuntu:/data/svn# ll
total 12
drwxrwxrwx 3 root root 4096 Apr 11 19:34 ./
drwxr-xr-x 4 root root 4096 Apr 11 19:30 ../
drwxr-xr-x 6 root root 4096 Apr 11 19:34 repository/
root@ubuntu:/data/svn# cd repository/
root@ubuntu:/data/svn/repository# ll
total 32
drwxr-xr-x 6 root root 4096 Apr 11 19:34 ./
drwxrwxrwx 3 root root 4096 Apr 11 19:34 ../
drwxr-xr-x 2 root root 4096 Apr 11 19:34 conf/
drwxr-sr-x 6 root root 4096 Apr 11 19:34 db/
-r--r--r-- 1 root root 2 Apr 11 19:34 format
drwxr-xr-x 2 root root 4096 Apr 11 19:34 hooks/
drwxr-xr-x 2 root root 4096 Apr 11 19:34 locks/
-rw-r--r-- 1 root root 246 Apr 11 19:34 README.txt
# 对db进入权限设置
root@ubuntu:/data/svn/repository# chmod -R 777 db
root@ubuntu:/data/svn/repository# ll
total 32
drwxr-xr-x 6 root root 4096 Apr 11 19:34 ./
drwxrwxrwx 3 root root 4096 Apr 11 19:34 ../
drwxr-xr-x 2 root root 4096 Apr 11 19:34 conf/
drwxrwsrwx 6 root root 4096 Apr 11 19:34 db/
-r--r--r-- 1 root root 2 Apr 11 19:34 format
drwxr-xr-x 2 root root 4096 Apr 11 19:34 hooks/
drwxr-xr-x 2 root root 4096 Apr 11 19:34 locks/
-rw-r--r-- 1 root root 246 Apr 11 19:34 README.txt
设置访问权限
root@ubuntu:/data/svn/repository# cd conf/
root@ubuntu:/data/svn/repository/conf# vim svnserve.conf
按照下图配置
添加用户
root@ubuntu:/data/svn/repository/conf# vim passwd
设置用户权限
添加admin组和user_r组,权限分别为读写和只读
root@ubuntu:/data/svn/repository/conf# vim authz
测试
# 启动svn服务器
root@ubuntu:/data/svn/repository/conf# svnserve -d -r /data/svn/
# -d:表示在后台运行
# -r:指定服务器的根目录
# 查看是否启动成功
root@ubuntu:/data/svn/repository/conf# ps aux | grep svnserve
root 3976 0.0 0.0 73488 940 ? Ss 20:25 0:00 svnserve -d -r /data/svn/
root 3989 0.0 0.0 14220 1080 pts/0 S+ 20:27 0:00 grep --color=auto svnserve
# 停止服务器
root@ubuntu:/data/svn/repository/conf# killall svnserve
# 检查进程是否存在
root@ubuntu:/data/svn/repository/conf# ps aux | grep svnserve
root 4004 0.0 0.0 14220 1080 pts/0 S+ 20:29 0:00 grep --color=auto svnserve
安装TortoiseSVN,输入svn地址:svn://IP/repository,输入用户名和密码,上传文件。