Set up a Subversion server in Windows

Source: Internet
Author: User
Tags http authentication subversion client tortoisesvn
Document directory
  • 3.1 install the independent server svnserver
  • 3.2 install the apachesvn Server
[Switch] installing a Subversion server in Windows (http://indian.blog.163.com/blog/static/10881582007112415021751)

Key words: Subversion installation configuration permission Directory Access

 

1 Preface
2 Basic Concepts
2.1 What is Version Control
2.2 What is Subversion
Repository)
3. install and configure
3.1 install the independent server svnserver
3.2 install the apachesvn Server
4 FAQ
5 References

 

1. Preface

 

It took 72 hours to get a preliminary grasp of the subversion. From a layman who doesn't even know "what is Version Control" to a hacker who configures access precise to each directory, there is still a day in the middle. I spent a lot of effort, tried many times, and almost gave up, but the harvest was huge. Now I have written down my configuration and learning process for your reference, which also helps beginners avoid detours.

The following uses Windows as an example. For more information about UNIX and Linux platforms, see. If there are any mistakes, including typos, please contact me for revision.

Technology advances in sharing!

 

2. Basic Concepts

 

2.1. What is version control?

To put it simply, version control is a data warehouse that records every change to the file. In this way, even if your boss says "no" after a few months of modification, you will not go crazy as you did in the past. simply restore the version to get everything done.

 

2.2. What is subversion?

Subversion is a free/open-source version control system that manages files and directories over time. A group of files are stored in the central version library. This version library is similar to a common file server, but it can record every modification to files and directories, this allows you to obtain a previous version of the data and check the changes. From this perspective, many people regard the version control system as a "time machine ".

Subversion can access its version library through the network, so that users can use it on different computers. To a certain extent, it can be said that it is to promote collaboration to allow users to modify the same data in their respective places. The progress may be very rapid, and there is no channel for all changes to achieve results. Because all jobs have historical versions, you do not have to worry about the impact of quality due to the loss of a channel, if an incorrect change exists, cancel the change.

Some version control systems are also Software Configuration Management (SCM) systems, which are specially designed to manage source code, there are many features about software development-Understanding programming languages themselves, or providing tools for building programs. However, subversion is not such a system. It is a general system that can manage all types of file sets. For you, this may be the source code, for others, it may be a goods quotation or a manuscript.

 

2.3. Version Library (repository)

The core of subversion is repository, which translates Chinese characters into "version libraries ". It is located on the server side where data is centrally managed and stored.

 

3. install and configure

 

3.1 install the independent server svnserver

Environment

OS: Windows XP SP2

Web: Apache 2.2.6

SVN: svn-win32-1.4.6

 

I. Preparations

1. Obtain the Subversion server program

Download the latest server installer from the official website (http://Subversion.tigris.org. The latest version is 1.4.6, specific in: http://Subversion.tigris.org/servlets/ProjectDocumentList? Folderid = 8100 & expandfolder = 8100 & folderid = 91. Find the version for Apache 2.2.x.

2. Obtain the tortoisesvn client program

Get the latest tortoisesvn from the official website http://tortoisesvn.net/downloads. Tortoisesvn is a client program used to communicate with the Subversion server. Subversion comes with a client program svn.exe, but tortoisesvn provides better operations and improves efficiency.

 

Ii. Install the server and client

First, install Apache 2.2.6. For more information about how to install Apache 2.2.x, or see install Apache 2.2.x in windows.

Next, install the subversion (SVN) server and client. The downloaded Server is a zip package, which can be decompressed directly. For example, I can decompress the package to E: \ subversion. The Client installation file is an EXE executable file. You can directly run the file and follow the prompts to install it. After the Client installation is complete, the system prompts you to restart.

 

3. Create a version Library (repository)

To run the Subversion server, you must first create a version Library (repository ). The version library can be seen as a place where data is centrally stored and managed on servers.

Create a version library. First, create an empty E: \ SVN folder as the root directory of all version libraries. Then, go to the command line and switch to the bin directory of subversion (use the command prompt in Windows ). Run the following command:

Svnadmin create E: \ SVN \ repos1

This command creates a version library repos1 under E: \ SVN. Some folders and files are automatically generated under repos1.

We can also use tortoisesvn to perform this step graphically:

First, create an empty directory e: \ SVN \ repos1. Note that it must be empty. Right-click the repos1 folder and choose tortoisesvn> Create repository here... ", then you can select the version library mode. Here you can use the default fsfs, and then create a series of folders and files, which are the same as those created on the command line.

 

4. Run an independent server

At this time, the Subversion service has not started yet, but the version library has been created through its command. Enter the following in the Command window:

Svnserve.exe -- daemon

Svnserve will wait for the request on port 3690, and the -- daemon (two dashes) Option tells svnserve to run in daemon mode, so that it will not exit before manual termination. Do not close the command line window. Close the window will stop svnserve.

To verify that svnserve works properly, use tortoisesvn-> repo-browser to view the version library. In the pop-up URL dialog box, enter:

SVN: // localhost/SVN/repos1

Click "OK" to view the directory tree structure of the repos1 version library, but repos1 is an empty database.

You can also use the -- root option to set the root location to restrict the access directory of the server, so as to increase security and save time for inputting the svnserve URL:

Svnserve.exe -- daemon -- root drive: \ path \ To \ Repository

In the previous test, svnserve runs as follows:

Svnserve.exe -- daemon -- root E: \ SVN

Then the browser URL in tortoisesvn is reduced:

SVN: // localhost/repos1

 

5. Configure users and permissions

Open the E: \ SVN \ repos1 \ conf directory in the text editor and modify svnserve. conf:

Set:

# Password-DB = passwd

Changed:

Password-DB = passwd

Remove the # annotator. Note that there is no space before it.

Then modify the passwd file in the same directory and add an account:

Set:

[Users]
# Harry = harryssecret
# Sally = sallyssecret

Add an account:

[Users]
# Harry = harryssecret
# Sally = sallyssecret
Test = test

 

Vi. initialize Import

The following describes how to import our data (project) to this version library and manage our data in the future. Any changes we make will be recorded by the version library. Even if we lose or correct the data, the version library will help us retrieve the data.

For example, I have a guestbook folder under D: \ wwwroot, which stores the message book program I wrote. In this folder, right-click and choose tortoisesvn> Import.... In the displayed dialog box, enter "SVN: // localhost/repos1/Guestbook" in URL of repository ". Enter "import entire Guestbook" in "Import message" as a comment.
After clicking OK, enter the account. Enter test in both the user name and password. After completion, all content in the guestbook is imported to SVN: // localhost/SVN/repos1/guestbook.

We can see that there is no change in E: \ SVN \ repos1, and even a guestbook folder is not created. The only change is that the capacity of E: \ SVN \ repos1 has increased. In fact, the content in the source guestbook has already been imported into the repos1 version library, and the source guestbook folder can be deleted.

Note that this step can be performed on another client with tortoisesvn installed. For example, if the IP address of the host running svnserve is 133.96.121.22, the content entered in the URL section is "SVN: // 133.96.121.22 ".

 

VII. Basic operation procedure

1. Check out)

Extract the version library to a working copy:

To any empty directory, such as creating an empty folder F: \ work in partition F. "Right-click-> SVN checkout ". In "URL of repository", enter "SVN: // localhost/SVN/repos1/Guestbook". In this way, we get a copy of the content in the gstbook.

2. Check in/commit)

Make changes in the work copy and submit:

Open a file in the copy of Guestbook and modify it. Right-click and choose SVN commit ...". In this way, the modifications are submitted to the version library, which stores the submitted data as needed.

Right-click the modified file and choose tortoisesvn> show log to view all submissions to the file. Right-click different revision entries and choose "compare with working copy". We can compare the differences between the files that work copies and the selected revision version.

 

 

3.2 install the apachesvn Server

The Subversion design includes an abstract network layer, which means that the version library can be accessed through various server processes. Theoretically, subversion can be implemented using an infinite number of network protocols. Currently, there are two types of servers in practice.

 

  • Svnserver: svnserve is a small (also called Lightweight) independent server that uses its own protocol and client. (Note: I call this type of server "svnserver server". The above installation configuration is to install the svnserver server .)

  • Apachesvn: Apache is the most popular Web server. By using the mod_dav_svn module, Apache can access the version library and allow the client to access it using the HTTP extension protocol WebDAV/DeltaV. (Note: I call this server "apachesvn server ")

 

Accessing the version library through HTTP is one of the highlights of subversion.Apachesvn ServerWith manySvnserve ServerWithout features, it is more flexible to use, but a little difficult to configure, flexibility usually brings complexity.

Because the Subversion requires version control, the standard HTTP Protocol cannot meet the requirements. To make Apache and subversion work together, you need to use WebDAV (web-based Distributed Authoring and Versioning :) Web Distributed creation and version control ). WebDAV is an extension of HTTP 1.1. For the specifications and working principles of WebDAV, refer to ietf rfc 2518.

 

I. Prerequisites

To enable your version library to use the HTTP network, you must meet the following conditions:

  1. Configure httpd 2.2.x and start with mod_dav.
  2. Install the mod_dav_svn plugin for mod_dav.
  3. Configure your httpd. conf so that the HTTP protocol can access the version library.

The following describes the configuration process in detail.

Environment:

OS: Windows XP SP2

Web: Apache 2.2.6

SVN: svn-win32-1.4.6

 

Ii. Installation

1. install Apache

For specific installation methods, see install Apache 2.2.x in windows.

2. Install Subversion

Unzip the downloaded svn-win32-1.4.6.zip directly, for example, to E: \ subversion.
Copy intl3_svn.dll, libdb44.dll, mod_authz_svn.so, and mod_dav_svn.so to the Module Directory of Apache (the modules folder of the Apache installation directory) from the bin subdirectory of the Subversion installation directory ).

 

III. Basic Apache configuration

Modify Apache configuration fileHttpd. conf, Use loadmodule to load the mod_dav_svn module.

Set:

# Loadmodule dav_module modules/mod_dav.so

Changed:

Loadmodule dav_module modules/mod_dav.so

Remove the previous.

Add:

Loadmodule dav_svn_module modules/mod_dav_svn.so

Make sure it is after mod_dav.

Now you have set Apache and subversion, but Apache does not know how to handle the Subversion client, such as tortoisesvn. To let Apache know which directory is used as the Subversion library, you need to use the Editor (such as NotePad) to edit the Apache configuration file.

Add the following lines at the end of the configuration file:

<Location/Repository/>
Dav SVN
Svnpath E:/SVN/repos1
</Location>

This configuration tells Apache to first enable dav_module and then load dav_svn_module. The external URL of the version library is http: // server IP/Repository/. All the Subversion versions are physically located at E:/SVN/repos1 /.

After the configuration is complete, restart Apache. Open the browser and enter http: // server IP Address/Repository/. The following figure is displayed:

This indicates that the dav_svn module of Apache is working properly. You can use any subversion client to access your version library through the HTTP protocol.

If you want to specify multiple version libraries, you can use multiple location tags, or use svnparentpath instead of svnpath. For example, there are multiple version libraries repos1 and repos2 under E: \ SVN, use the following method:

<Location/Repository/>
Dav SVN
Svnparentpath E:/SVN
</Location>

"Svnparentpath E:/SVN" indicates that each subdirectory under E: \ SVN is a version library. It can be accessed through http: // server IP/Repository/repos1/, http: // server IP/Repository/repos2.

Now, anyone in your version library can access it and have full write operation permissions. That is to say, anyone can read, modify, submit, and delete the content in the version library anonymously (Note: you do not need to configure E: \ SVN \ repos \ conf \ svnserve. CONF file, and do not need to start E: \ subversion \ bin \ svnserve.exe. Because the submission is processed by the Apache Dav module, rather than by the svnservice .). We use the tortoisesvn client for verification.

Obviously, this is not suitable for most cases. Apache provides the following basic permission settings:

 

Iv. authentication options

1. Basic HTTP Authentication

The simplest method of client authentication is to use the basic HTTP authentication mechanism and simply use the user name and password to verify the identity of a user. Apache provides an htpasswd tool to manage a user file, which contains the user name and the encrypted password. These are the users you want to grant subversion special permissions. Htpasswd can be found in the bin installation directory of Apache. The usage is as follows:

Create a user file:
Htpasswd-c e: \ USR \ apache2.2 \ bin \ passwd. conf Username

Add a new user (-M indicates that the password is encrypted with MD5, optional ):
Htpasswd [-M] E: \ USR \ apache2.2 \ bin \ passwd. conf newusername

Change User Password:
Htpasswd [-M] E: \ USR \ apache2.2 \ bin \ passwd. conf Username

Delete a user (use uppercase D ):
Htpasswd-d e: \ USR \ apache2.2 \ bin \ passwd. conf Username

Next, modify httpd. conf and add the following content to the location Tag:

Authtype basic
Authname "SVN repos"
Authuserfile E:/usr/apache2.2/bin/passwd. conf
Require valid-user

Note:

Authtype basic: enable basic authentication, such as a user name/password pair.

Authname "SVN repos": information displayed in the authentication dialog box when an authentication dialog box is displayed. (It is best to use English. tortoisesvn does not support Chinese characters, except for language packs .)

Authuserfile E:/usr/apache2.2/bin/passwd: Specify E: \ USR \ apache2.2 \ bin \ passwd as the user file to verify the user name and password.

Require valid-user: restrict users to access this path only after entering the correct user name and password.

 

Restart Apache and open a browser to access the version library. Apache will prompt you to enter the user name and password to authenticate and log in. Now, only the user set in the passwd file can access the version library. You can also configure that only specific users can access the repository. Replace "require valid-user" with "require user Tony Robert" and only Tony and Robert in the user file can access the repository.

Sometimes such strict access control is not required. For example, most open-source projects allow anonymous read operations, and only authenticated users allow write operations. To implement more detailed permission authentication, you can use the limit and limitlimit t tags. For example:

<Limitaskt get PROPFIND Options Report>
Require valid-user
</Limit10000t>

The preceding configuration grants anonymous users the read permission, and only users configured in passwd can use the write operation.

If this does not meet your requirements, and you want to precisely control the version library directory access, you can use the mod_authz_svn module of Apache to authenticate each directory.

 

 

2. Use mod_authz_svn for Directory Access Control

First, let Apache load the mod_authz_svn module. Find the mod_auth_svn module in the Subversion installation directory and copy it to the modules subdirectory of the Apache installation directory. Modify the httpd. conf file and add:

Loadmodule authz_svn_module modules/mod_authz_svn.so

Now you can use authz in the location tag. A basic authz configuration is as follows:

<Location/Repository/>
Dav SVN
Svnparentpath E:/SVN

# Our access control policy
Authzsvnaccessfile E:/usr/apache2.2/bin/accesspolicy. conf

# Try Anonymous Access first, resort to real
# Authentication if necessary.
Satisfy any
Require valid-user

# How to authenticate a user
Authtype basic
Authname "Subversion repository"
Authuserfile E:/usr/apache2.2/bin/passwd. conf
</Location>

Authzsvnaccessfile refers to the policy file of authz. Detailed permission control can be specified in this policy file. Access File accesspolicy. conf syntax and svnserve. conf is very similar to the Apache configuration file, and the lines starting with (#) are ignored. In its simple form, each section names a version library and a path; the authenticated user name is the option name in each section. The value of each option describes the level at which the user accesses the version Library: R (read-only) or RW (read/write ), if the user does not mention it or the value is left blank, access is not allowed; * indicates that all users use it to control the access permissions of anonymous users; @ symbol area grouping and users. For example:

[Groups]
Committers = paulex, Richard
Developers = Jimmy, micel, spark, Sean

[/]
* = R
@ Committers = RW

[/Branches/dev]
@ Developers = RW

[/Tags]
Tony = RW
[/Private]
* =
@ Committers = r

When svnparentpath is used instead of svnpath to specify the parent directory of multiple version libraries, all version libraries are configured according to this policy file. For example, in the above example, Tony will have read and write permissions on the/tags directory in all versions. To configure a specific version library, use the following syntax:

[Groups]
Project1_committers = paulex, Richard
Project2_committers = Jimmy, micel, spark, Tony, Robert

[Repos1:/]
* = R
@ Project1_committer = RW

[Repos2:/]
* = R
@ Project2_committer = RW

In this way, the project1_committer group of Project 1 can only have the write permission on the files in the repos1 version library, but cannot modify the version library repos2. Likewise, the project2_commiter group of Project 2 cannot modify the files in the repos1 version library.

 

 

4. FAQs

1. If the path or permission is insufficient, an error message is displayed:

Http: // localhost
Error * PROPFIND reqst failed on '/'propfind of'/': 200 OK (http: // localhost)
(Path incorrect)

 

Http: // localhost/SVN
Error * PROPFIND reqst failed on '/SVN' PROPFIND of '/SVN': 403 forbidden (http: // localhost)
(Insufficient permissions)

 

Http: // localhost/SVN/Repos
(Normal display)

 

Http: // localhost/Repos
Error * PROPFIND reqst failed on '/repos' PROPFIND of'/repos': 405 method not allowed (http: // localhost)
(Permission not allowed)

 

 

2. Do not start E: \ subversion \ bin \ svnserve.exe, but start apachesvn. The access (tortoisesvn-> repo-browser) or commit (SVN commit) situations are as follows:

Symptom: SVN: // localhost/SVN/repos cannot be accessed or submitted. The following error occurs: Error * can't connect to host 'localhost': Unable to connect because the target machine is actively rejected. However, file: // E:/SVN/repos and http: // localhost/SVN/repos can be accessed or submitted.

Cause: SVN: // The Protocol of the independent server svnserver. File: // local access, that is, the server and client are on the same machine.

 

 

References:
Official website of Subversion: the official website of subversion, which provides the most authoritative introduction and the latest download.
Subversion Chinese Manual: A Chinese manual for translation of the Subversion official Chinese website.
Tortoisesvn Chinese document: tortoisesvn Chinese document translated from the Subversion Chinese official website.
I use SVN Chinese Forum: SVN Chinese forum that is very popular in China.
Build a secure version control environment using Apache and Subversion: a Linux-based SVN tutorial written by IBM engineers.
Baidu Encyclopedia: an encyclopedia jointly written by all netizens

 

~ Full text ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.