Build SVN server under CentOS7.5

Ready to work:

1. Let SVN's default port 3690

firewall-cmd --zone=public --add-port=3690/tcp --permanent
firewall-cmd --reload

 

View all open ports:

firewall-cmd --zone=public --list-ports

 

2. Turn off SELinux

vim /etc/selinux/config

Default: SELINUX=enforcing

Modified to: SELINUX=disabled

image

 

Save and exit, and restart the system, SELinux will take effect

After the system restarts, check the status of SELinux

getenforce

image

installation steps

1. Check if it is installed

rpm -qa | grep subversion

If you want to uninstall the old version:

yum remove subversion

2. Installation

yum install subversion

image

3. Check if the installation is successful

# If the installation is successful, the version number will be output

svnserve --version

image

4. Create a warehouse directory

For example, create a warehouse /home/guoke/svn as the directory to be created for the svn warehouse

cd /home
mkdir guoke
/home/guoke/svn
svnadmin create /home/guoke/svn

After executing the above command, the following files will be generated in the /home/guoke/svn directory

image

5. Enter the conf directory (the svn version library configuration file)

cd /home/guoke/svn/conf/
ll

image

 

authz file is permission control file

The passwd file is the account password file

The svnserve.conf file is the SVN service configuration file

6. Set account password

vim /home/guoke/svn/conf/passwd

Add user and password in the [users] block, format: account = password, such as lab505=654321

 

Note: Do not use spaces, write in the top box

chengjiye=chengjiye

image

7. Modify the svnserve.conf file

vim /home/guoke/svn/conf/svnserve.conf

Delete the comment symbols of the following commands: (Note: there can be no spaces before the commands, otherwise an error will occur )

anon-access = read # Anonymous users can read, change to none, prohibit anonymous access

auth-access = write # Authorized users can write

password-db = passwd # Which file to use as the account file

authz-db = authz # Which file to use as the authority file

realm = /home/guoke/svn # Certification space name, the directory where the repository is located


image

8. Modify the configuration authz file

vim /home/guoke/svn/conf/authz

This configures the permissions of different accounts in different projects and different directories.

Note: There can be no spaces before the command, otherwise an error will occur

The following configuration is that the lab505 user has read and write permissions to the svn project, and other accounts have no access permissions (note: be sure to add [/] before lab505=rw,

Indicates which folder can be read and written, this is the root directory, otherwise an authorization failed error will appear when fetching files from svn.

Remember to remember! ! !)

[groups]

[/]

chengjiye=rw

image

9. Modify the configuration file of svnserve and specify the path of the version library

vim /etc/sysconfig/svnserve

Default: OPTIONS="-r /var/svn"

Modified to: OPTIONS="-r /home/guoke/svn"

image

Save and exit!

10.svn commonly used commands

1. Start SVN

systemctl start svnserve

2. Add self-start after booting

systemctl enable svnserve

image.png

3. Check SVN status

systemctl status svnserve

image.png

4. You can also start the specified SVN version library

svnserve -d -r /home/guoke/svn

 

The description and usage of the svnserve command are as follows.

Description: SVN server program

Usage: svnserve [options]

Option: -d # Run svnserve as a daemon (runs in the background as a service program)

   -r # Specify a virtual path for the version library, the default client must specify an absolute path to access the library

   --listen-port=port # Specify the listening port, the default listening port number is 3690

11. TortoiseSVN client connection test

First install the SVN client, the tortoise client is generally selected for Windows systems https://tortoisesvn.net/downloads.html

Guide for newcomers using TortoiseSVN client http://blog.csdn.net/maplejaw_/article/details/52874348

Enter the repository URL svn://xxx.xxx.xxx.xxx:3690/ and click OK, and a dialog box will pop up to enter the user name and password set before, and click OK to successfully check out the files in the svn service directory.

image

Check out successfully!

image

12. Check the process and listening port (the default port of the svn server is 3690)

ps -ef | grep svn
netstat -antlp | grep 3690

image

13 Create svn branch

svn import -m "create test file trunk" /home/guoke/svn/trunk/ svn://localhost/svn/trunk/
svn import -m "create test file trunk" /home/guoke/svn/document/ svn://localhost/svn/document/

 

Explanation:

/home/guoke/svn/trunk/ is the directory of the server

 

svn/trunk/ corresponds to the same location in /home/guoke/svn/trunk/

 

svn://192.168.1.64:3690/svn/trunk

 

svn://192.168.124.14:3690/svn/document

 

svn://192.168.124.64:3690/svn/document

 

14. Summary

The problems are basically caused by the following three configuration files, which are listed below

1. File svnserve.conf:

[general]

anon-access = none

auth-access = write

password-db = passwd

authz-db = authz

realm = /home/guoke/svn

2. File passwd:

[users]

lab505 = 654321

3. File authz:

[groups]

[/]

lab505 = rw

Authorization failed exception occurs, usually in the authz file, the user group or user permissions are not configured, as long as you set [/], it represents all the resources in the root directory. If you want to limit the resources, you can add subdirectories.

15. In which directory on the SVN server is the uploaded file placed?

The SVN server version library has two formats, one is FSFS, and the other is BDB. After uploading the file to the SVN repository,

The uploaded file is no longer stored in the original format of the file, but is compressed into version library data by svn in its custom format, and stored in the version library.

If it is in FSFS format, these data are stored in the db directory of the repository, and the revs and revprops in it store the difference data and log information submitted each time.

 

At present, the most commonly used method is the FSFS method. In this method, it is generally stored in the \db\revs folder. There are a bunch of files named after the version number, such as: 0, 1, 2, 3, 4... ...That's it. svn first compresses the state of version 0 into 1 file, and then makes a compressed file for the changed part every time the version is updated, each time an incremental package is added, and finally the file name from the server can be seen A series of files starting from 0 to the final version.

 

SVN, short for Subversion, is an open source version control system. Compared with RCS and CVS, it uses a branch management system. Its design goal is to replace CVS. Many version control services on the Internet have migrated from CVS to Subversion. To put it simply, SVN is used for the purpose of multiple people jointly developing the same project and sharing resources.

 

Common questions:

svnserve.conf: Option expected problem solution

Often novices configure the subversion server based on svnserve,

This error occurs when the client accesses the subversion repository:

svnserve.conf:12: Option expected

Why does this error occur, because when subversion reads the configuration file svnserve.conf, it cannot recognize the configuration file with leading spaces, such as

### This file controls the configuration of the svnserve daemon, if you

### use it to allow access to this repository. (If you only allow

### access through http: and/or file: URLs, then this file is

### irrelevant.)

### Visit http://subversion.tigris.org/ for more information.

[general]

### These options control access to the repository for unauthenticated

### and authenticated users. Valid values are "write", "read",

### and "none". The sample settings below are the defaults.

anon-access = read

auth-access = write

Like the above configuration file, anon-access is the top line, no problem, and auth-access has a leading space, which will cause this error.

To avoid this error, you should remove the preceding spaces when removing the # before these lines.

Guess you like

Origin blog.csdn.net/qq_39999478/article/details/111386433