Construction and configuration of linux svn server

Today I learned about the construction process of the svn server, which is recorded as follows:

Check if svn is installed:

rpm -qa subversion #Check the existing version, if there is no prompt after entering the command, it means that it is not installed
yum remove subversion #If it is installed, you can use this command to uninstall the old version of the svn service
yum -y install subversion #Execute the installation

Create the svn directory:

mkdir /home/svn #New svn warehouses will be created in this directory in the future

Create an svn version repository:

svnadmin create /home/svn/firstrepo #Create a firstrepo repository under /home/svn, you can view the directory after executing the command

View the generated folder under the repository:

When creating a repository, there will be the following folders in the directory, as shown below


The conf directory is the directory configured for the svn repository, and then the files in the directory need to be configured.

Every time a svn version repository is created, there will be these files

The introduction and configuration method of each file in the conf directory

passwd file : svn user information file, saves all svn users of this repository, you can edit this file to add users.

Use: add the format as username = password , such as root = 123456    , keep a space on both sides of " ="

When the svn client is checked out or updated in the future, you can use the username and password in this file to log in for authentication.

authz file: Configure the group of each user, the permissions of the group (read or write), the svn project directory pointed to by the group, etc.

As shown below:

mygroup is the group name, the root on the right is the username, the username should exist in the passwd file, if there are multiple usernames separated by commas

The following specifies the permissions directory corresponding to the group, and the permissions it has

Permission directory format: [Repository name: directory with permissions], such as [firstrepo:/], / means the root directory, or [firstrepo:/xxx/xxx], which means there are permissions in multi-level subdirectories. In addition, Permissions can be inherited. For example, if a group has a certain permission on a certain directory, then he has that permission on all subdirectory files in the directory.

Permission type: read r write w no permission is empty, such as @mygroup = rw, it means that mygroup group has read and write permissions, * = r means that all users except mygroup group have read permission, if it is * = , it means that except All other users outside the mygroup group do not have permission to this directory.


svnserve.conf file: Basic global configuration of the svn repository.

vi svnserve.conf
Open the 5 comments below
anon-access = read # Readable by anonymous users
auth-access = write #Authorized users can write
password-db = passwd #Which file is used as the account file
authz-db=authz #Which file to use as the authority file
realm = /home/svn # Authentication space name, the directory where the repository is located

Start the svn service:

ps -aux|grep svnserve #Find whether the service is running, if it is running, kill the service first
kill -9 ID号
svnserve -d -r /home/svn #Start svn service

Notice:

  1. The directory specified when starting the service is important, the directory is the root directory, relative to the path specified in the configuration file.
  2. Every time you modify the configuration file, any one of the first three files, you need to restart the svn service.

Import your project into the svn repository:

Format: svn import your local project folder path file:///home/svn/svn project folder name -m "version note"

Example:

svn import /home/testsvn file:///home/svn/firstrepo/mytest -m 'import first'

As above, first of all, the /home/testsvn folder must exist, which is your local folder path, that is, the project path you want to import, and secondly mytest is the project name in your svn repository. When you check out the project, the svn address It's the name that follows. -m 'Import first' is a comment for the imported project.

Test checkout the project on the server:

svn co svn://192.168.xx/firstrepo/mytest #The middle is your server ip, followed by the version library name and checkout project name

The windows svn client checks out the project:

First install the svn client, such as the tortoise svn client. The specific installation method is not introduced here.

After installation, go to a directory where you want to put the svn project, right click svn checkout


Fill in your repository project address, such as: svn://192.168.xx/firstrepo/mytest

Which directory to check out, such as: E:\work\testsvn The    testsvn directory can be created automatically without creating it first

Click ok, you will be prompted to enter the username and password, which is the username and password added in the previous authz file. If you are not prompted to enter the username and password at this time, the checkout will be performed directly or the checkout will fail. There may be the following reasons. :

  1. In the authz file, the anon-access parameter is not set to none. To be set, anon-access = none.
  2. Did not restart the svn service.
  3. The svn client does not clear the login cache information of the user password, it will use your previous login information to verify, so it needs to be cleared, the clear method: right click "tortoisesvn" settings , find saved data on the left menu , find authentication data on the right , and then click clear all , clear save. Then check out again, you will find that you need to log in to successfully check out.

The method described above establishes a svn independent server, and the access method is in the format of svn://ip address/xxx/xxx to view the checked out items.

If you want to check out the access project by http://ip address/xxx/xxx, you need to configure the http support of the svn server. Specifically, you need to install the apache server and run svn as a module of apache. How to install and configure it Chapter one.

summary of a problem:

After the svn import or svn commit command is successful, why can't I find the imported or uploaded original files in the server's svn repository directory?

The SVN server does not simply store the uploaded files one by one;
the FSFS format adopted by the SVN server by default stores the content of each commit incrementally, and each incremental package is stored as one file. The package contains all the data of this commit.
That is to say, it is impossible for you to find a file you uploaded in the folder where the repository is stored on the server side.

The storage method of SVN on the server side is different from that on the client side, so the source file cannot be seen on the server side. There are two storage methods on the server side, FSFS and BDB. Currently, the default is FSFS.

How to set the svn client to require a username and password when logging in?

Modify svnserve.conf , anon-access = none, do not allow anonymous access, save, restart the svn service.
svn does not support Chinese path solution? 
See the article: https://blog.csdn.net/clever101/article/details/17960241
How does the directory specified by the svnserve startup parameter -r affect the authz configuration file?
See article: https://blog.csdn.net/linuxin/article/details/2783835

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325171937&siteId=291194637