Centos7 configures SVN server

Environmental Science

Centos 7

SVN 1.7

Install SVN

Shell> yum install svn -y

Prepare configuration and warehouse

Shell> mkdir -p /mydata/repo
Shell> cd /mydata/repo/
Shell> svnadmin create erp  #Create a code base, here take erp as an example

The configuration file of the code base is located in / mydata/repo/erp/conf /. There are three files in total, which are modified one by one.

Modify the general configuration file svnserve.conf

[general]
anon-access = none      #Disable anonymous access
auth-access = write      #Login user can have write permission
password-db = passwd     #Profile for user name and password
authz-db = authz       #Profile for user rights
realm = My SVN Repository  #Description text of the warehouse

Modifying the configuration file passwd for users and their passwords

[users]
user1 = 111
user2 = 222
user3 = 333

Modify the configuration file authz of permissions

[groups]  #User groups. It is recommended that all users be configured to groups for convenient permission management. A single user can exist in multiple groups
admin = user1     #Administrators
common = user2,user3 #Ordinary users

[/]    #Root directory. The configuration here is also the default permission of the library
@admin = rw  #Administrators have all read and write permissions by default
* =       #No other permissions by default

[/trunk]  #Backbone. The administrator not specified here will inherit the read and write permissions of the root directory. The same below
@common = rw  #Ordinary users have read and write permission

[/branches]  #branch
@common = rw  #Ordinary users have read and write permission

[/tags]  #sign
@common = r  #Ordinary users only have read permission

Note: these three configuration files do not need to be restarted after modification to take effect.

Configure svnserve service

Modify the configuration file / etc/sysconfig/svnserve, and specify the root directory through - r

OPTIONS="-r /mydata/repo/erp"

The default port is 3690. If you need to modify it, you can add -- listen port [port] to OPTIONS

By default, the log is not printed. You need to add -- log file [file] to OPTIONS

Start and configure power on auto start

Shell> systemctl start svnserve
Shell> systemctl enable svnserve

Test use

After entering the user name and password for the first time, you will be prompted to save it. You do not need to enter it again later

If you don't want to save or you don't want to always prompt to save, each svn command adds these three parameters: - username user1 -- password 111 -- no auth cache

Shell> svn mkdir svn://localhost/{trunk,branches,tags} -m 'create base directory'
Shell> svn co svn://localhost/trunk
Shell> cd trunk/
Shell> touch 1.txt
Shell> svn add *
Shell> svn ci -m 'Add file 1.txt'
Shell> svn up
Shell> svn log
------------------------------------------------------------------------
r2 | user1 | 2020-01-10 12:14:32 +0800 (Five, 2020-01-10) | 1 That's ok

//Add file 1.txt
------------------------------------------------------------------------
r1 | user1 | 2020-01-10 12:10:23 +0800 (Five, 2020-01-10) | 1 That's ok

//Create base directory
------------------------------------------------------------------------

Multi database mode

In the above, the root directory of the library points directly to erp, indicating that this is a single library mode. There is only one project library for this svn service. If there are other projects under / mydata/repo, such as oa, crm, etc

Then you need to point the root directory to the parent directory and modify / etc/sysconfig/svnserve

OPTIONS="-r /mydata/repo"

Then you need to add the project name when accessing, for example:

Shell> svn ls svn://localhost/erp

In addition, it should be noted that each project uses the configuration files in its conf directory, which need to be maintained separately.

However, you can specify the shared configuration through the parameter -- config file. For example, copy the erp configuration to / etc/svnserve/conf as the shared configuration. You need to modify / etc/sysconfig/svnserve

OPTIONS="-r /mydata/repo --config-file /etc/svnserve/conf/svnserve.conf"

Then, you need to modify / etc/svnserve/conf/authz to add the project name:

[erp:/]
@admin = rw
* =

[ao:/]
@admin = rw
* =

[erp:/trunk]
@common = rw

...slightly...

Note: if you use the -- config file parameter, you must restart the svnserve service to take effect after modifying the configuration file. In addition, when there are many projects, the permissions are usually complex. It is recommended that each project use its own configuration.

Single library multiple

Of course, small scale and uncomplicated permission assignment also exist. This can be considered to use the single library mode (the library name can use the company name), and then the items in the library can be distinguished by folders:

repo/
└── mycompany
    ├── crm
    │   ├── branches
    │   ├── tags
    │   └── trunk
    ├── erp
    │   ├── branches
    │   ├── tags
    │   └── trunk
    └── oa
        ├── branches
        ├── tags
        └── trunk

 

Published 40 original articles, won praise 5, visited 10000+
Private letter follow

Keywords: svn shell CentOS yum

Added by bdee1 on Mon, 20 Jan 2020 09:33:04 +0200