Install SVN server on Ubuntu

参考以下步骤可以实现对代码库和代码库中路径的访问权限管理

sudo apt-get update
sudo apt-get install subversion apache2 libapache2-mod-svn apache2-utils
sudo mkdir -p /svn/repos/
sudo svnadmin create /svn/repos/testrepo
sudo chown -R www-data:www-data /svn/repos/testrepo
  • 安装证书
openssl req -new -x509 -days 3650 -sha1 -newkey rsa:4096 -nodes -keyout example.key -out example.cert -subj '/O=Company/OU=Department/CN=svn.example.com'
sudo mv example.* /svn/
sudo a2enmod ssl
  • 启用SVN访问的身份认证
$ sudo vim /etc/apache2/sites-available/svn-server.conf
<VirtualHost *:443>
    ServerName svn.example.com
    SSLEngine On
    SSLCertificateFile [YOUR_SVN_CERT_FILE]
    SSLCertificateKeyFile [YOUR_SVN_KEY_FILE]
    ErrorLog /var/log/svn.log
    <Location />
        DAV svn
        SVNParentPath [your-svn-repos-root-dir]
        SVNListParentPath off
        ModMimeUsePathInfo On
        AuthType Basic
        AuthName "My SVN - Private"
        AuthUserFile /your-path/svnpasswd
        AuthzSVNAccessFile /your-path/svnauthz
        Require valid-user
    </Location>
</VirtualHost>
  • 设置用户名和密码
$ sudo htpasswd -c ./svnpasswd [NEW_USER_NAME]
  • 编辑身份认证
[groups]
admin = administrator
groupA = user1, user2
groupB = user3, user4

[/]
@admin = rw
 
[repo1:/]
@group1 = rw
 
[repo2:/]
@group2 = rw