preface

This document explains how to set up the SVN server in Linux, and explains the functions of each configuration item in detail. In the end, the SVN can manage multiple complex configurations.

SVN is the abbreviation of Subversion, is an open source version control system, through the efficient management of branch management system, to achieve the final centralized management.

Many Internet companies use the SVN, which is easy to use and manage. Git, its distributed version control counterpart, is more flexible.

Set up

Install SVN

 //Ubuntu
 apt-get install subversion
 ​
 //Centos
 yum install subversion
Copy the code

Check whether the installation is successful. You can view the version.

 svnserve --version
Copy the code

If version 1.13.0 is displayed, the installation is successful.

Create the repository directory

This section describes how to create a SVN version library directory. This directory provides the storage location for the later creation of the SVN version library and is also the root directory for starting the SVN service.

We create the SVN directory under /usr as the repository directory.

 cd /usr
 mkdir svn
Copy the code

Linux system directory

Therefore, it makes sense to put the SVN inventory in the user file directory /usr.

Create the SVN version library

Based on the path created in the previous step, create a version library, such as dev.

 cd /usr/svn
 svnadmin create dev
Copy the code

After the creation, you can view the files generated in the dev directory.

Modifying SVN Configurations

Go to the conf directory and check the configuration file that you want to modify.

 cd /usr/svn/dev/conf
 ls
Copy the code

Configuration file:

  • Authz: Permission profile that controls read and write permissions
  • Passwd: indicates the account password configuration file
  • Svnserve. conf: configuration file of the SVN server

Modify the SVNserve. conf file

 vim svnserve.conf
Copy the code

Anon-access/auth-access/password-db/authz-db/realm

Meanings of configuration items:

  • Anon – access = none | read | write decided to unauthorized users access level. None indicates no access permission, read indicates read-only, and write indicates both read and write. The default value is read.
  • Auth – access = none | read | the write decide to authorized users access level, use the same as the above level of access. The default value is Write.
  • Password-db = filename specifies the account password database filename. Filename is the location of the conf directory in the relative repository or can be set to an absolute path. The default path is passwd.
  • Authz-db = filename specifies the permission configuration filename. Filename is the location of the conf directory in the relative repository or can be set to an absolute path. The default value is authz.
  • Realm = realm-name Specifies the authentication domain of the repository. That is, the authentication domain name prompted during login. If the authentication domains of the two databases are the same, you are advised to use the same account and password database file passwd.

Authentication domain knowledge extension:

When you log in to the SVN client, a realm authentication domain is displayed, such as My First Repository in the following figure.

Example Modify the passwd file

 vim passwd
Copy the code

You only need to add the account and password at the end. For example, user1 = 123456, you can add multiple accounts.

Modify the authz file

 vim authz
Copy the code

Set read and write permissions for user1 and user2 in the root directory:

Team1 = @team1; team1 = @team1; team1 = @team1;

If you want to set the permissions of other users, you can use * to set, for example, set the read-only permissions of other users except @team1 group:

 [/]
 @team1 = rw
 * = r
Copy the code

Starting the SVN Service

Run the SVN startup command. -d indicates that the SVN is started as a daemon process, and -r indicates the root directory.

 svnserve -d -r /usr/svn/
Copy the code

Disable the SVN command:

 killall svnserve
Copy the code

Access the SVN service locally

In Windows, install the TortoiseSVN software, create a local directory, right-click SVN Checkout, and fill in the URL SVN ://IP/dev. Dev is the name of the repository you created.

Enter passwd.

Checkout completed, SVN access successfully, this is Nice ~

extension

Set view log

To view the submitted SVN logs, you need to perform further configuration.

Edit svnserve.conf and set:

 anon-access = none
Copy the code

Edit authz file to add:

/ / * =Copy the code

You can use the TortoiseSVN-> Show log to view the history of SVN submission.

Multiple project management and control configuration

SVN configuration files are flexible. If you want to use the same account and permission to manage multiple projects, you can put the authz and passwd files of multiple projects in one place and configure the absolute paths of the two files in the SVNserve. conf file of multiple projects. And set user access rights for different projects in AuthZ.

For example, users A, B, C, and D have access to project P1 and project P2. Users A and B can access only P1, and users C and D can access only P2.

Create the repository directory

 mkdir /usr/svn
Copy the code

Create multiple version libraries

 cd /usr/svn
 svnadmin create p1
 svnadmin create p2
Copy the code

Create an administrative user permission directory

 mkdir /var/svn/conf
 cd /p1/conf
 cp authz passwd /var/svn/conf
Copy the code

Modifying a Configuration File

Modify the SVNserve. conf file in P1.

 anon-access = none
 auth-access = write 
 password-db = /var/svn/conf/passwd 
 authz-db = /var/svn/conf/authz 
 realm = p1 
Copy the code

Modify the SVNserve. conf file of P2:

 anon-access = none
 auth-access = write
 password-db = /var/svn/conf/passwd
 authz-db = /var/svn/conf/authz
 realm = p2
Copy the code

Password-db and authz-db both use the unified management user permissions directory, using an absolute path.

Modify the password-db file

 [users]
 a = 123
 b = 123
 c = 123
 d = 123
Copy the code

Modify the authz file

[groups] p1user = a,b p2user = c,d [/] * = # C and D cannot access @p1user = rw [p2:/] // P2 access control. A and B cannot access @p2user = rwCopy the code

The modification of the password-db and Authz files takes effect immediately without restarting the SVN.

Starting the SVN Service

 svnserve -d -r /usr/svn/
Copy the code

Access SVNS of different projects

For TortoiseSVN, use SVN Checkout.

Access item P1 URL SVN ://IP/ P1 Access Item P2 URL SVN ://IP/ P1Copy the code

A unified configuration file allows users to access different items. In this way, SVN configurations for multiple items can be controlled.

The above is the Linux system to build the SVN server tutorial all the content, I hope to help you.

Did you learn to “waste”?


The article first appeared in my blog echeverra.cn/svnserve, original article, reproduced please indicate the source.

Welcome to follow my wechat official account Echeverra to learn and make progress together! Uncertain when there are resources and welfare oh!