How to build an SVN server in WINDOWS (Subversion)

Source: Internet
Author: User
Tags http authentication rfc subversion client svn update tortoisesvn

1. Obtain the svn Program

2. 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. First create an empty directory E: \ svn \ repos1. Be sure to leave it empty. In the repos1 folder, right-click 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.
(Note that the svn server and the library directory must be under the same drive letter; otherwise, the system prompts that the directory cannot be found)

4. Go to the command line and switch to the bin directory of subversion. Run the following command:

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. closing the window will stop svnserve.

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

6. initialize the Import

(Make sure to perform Step 1 before doing this)
The following describes how to import our data (project) to this version library and manage our data in the future. Any of our changes are recorded by the version library. Even if we lose or correct the data, the version library can 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 "-> TortoiseSVN-> Import..." And enter "svn: // localhost/repos1/guestbook" in "URL of repository" in the pop-up dialog box ". In "Import message", enter "Import entire message book" as the 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/repo1/guestbook.
We can see that there is no change in e: \ svn \ repo1, and even a guestbook folder is not created. The only change is that the capacity of e: \ svn \ repo1 has increased. In fact, the content in the source guestbook has already been imported into the repo1 version library, and the source guestbook folder can be deleted.

7. svn configuration is complete. This is the simplest step. You can use it and then integrate svn into the system service. In the future, you do not need to open the command window. Paste the following content into a text file and rename it to *. bat,
SC create svnserver binpath = "C: \ Program Files \ Subversion \ bin \ svnserve.exe -- service -- root F: \ svn "displayname =" svnserver "depend = tcpip start = auto obj =" nt authority \ NetworkService"
C: \ Program Files \ Subversion \ bin \ svnserve.exe is the svn path.
F: \ svn is the version library directory
Displayname = "svnserver" is used to set the service name.
-- Root is used to set the root directory, for example: svn: // localhost/svn
When setting -- root F: \ svn, it must be abbreviated as svn: // localhost. Otherwise, Error: URL 'svn: // localhost/svn 'doesn' t exist

8. svn is ready for use. The following is the raw materials. If the above content cannot be met, please refer to the following content and hope you have not wasted valuable time. If you want the website to be updated synchronously, you can use the hook program as follows.

Subvision SVN (svn server) Installation Tutorial:
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/ser... 100 & folderID = 91, pay attention to find for apache 2.2.x version.

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. 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. In the repos1 folder, right-click 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/repo1

Click the OK button to view the directory tree structure of the repo1 version library, but repo1 is an empty library.

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/repo1

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 of our changes are recorded by the version library. Even if we lose or correct the data, the version library can 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 "-> TortoiseSVN-> Import..." And enter "svn: // localhost/repos1/guestbook" in "URL of repository" in the pop-up dialog box ". In "Import message", enter "Import entire message book" as the 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/repo1/guestbook.
We can see that there is no change in e: \ svn \ repo1, and even a guestbook folder is not created. The only change is that the capacity of e: \ svn \ repo1 has increased. In fact, the content in the source guestbook has already been imported into the repo1 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 and choose SVN Checkout ". In "URL of repository", enter "svn: // localhost/svn/repo1/guestbook" to get a copy of the content in the guestbook.

2. check in/commit)
Make changes in the work copy and submit:
In the copy of the guestbook job, open a file 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.

Tutorial on installing 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: The above installation configuration is used 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: This server is called "ApacheSVN server ")

Accessing the version library through Http is one of the highlights of Subversion. The ApacheSVN server has many features that the svnserve server does not have. It is more flexible to use, but it is 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 more information about WebDAV specifications and working principles, see ietf rfc 2518 (http://www.ietf.org/rfc/rfc2518.txt ).

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 it with mod_dav.
2. Install the mod_dav_svn plug-in 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 the Apache configuration file httpd. conf and 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 <

Br/> 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 Address/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/etc/svn/passwordfile username

Add a new user (-m indicates using MD5 to encrypt the password ):
Htpasswd [-m]/etc/svn/passwordfile Newusername

Change User Password:
Htpasswd [-m]/etc/svn/passwordfile username

Delete a user (use uppercase D ):
Htpasswd-D/etc/svn/passwordfile 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
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
</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 repos1 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 repos1 cannot modify the files in the repos1 version library.

FAQ:

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

Http: // localhost (incorrect path)
Error * PROPFIND request failed on ''/'' PROPFIND of ''/'': 200 OK (http: // localhost)

Http: // localhost/svn (insufficient permissions)
Error * PROPFIND request failed on ''/svn ''' PROPFIND of''/svn '': 403 Forbidden (http: // localhost)

Http: // localhost/svn/repos (displayed normally)

Http: // localhost/repos (permission not allowed)
Error * PROPFIND request failed on ''/repos '''propfind of''/repos '': 405 Method Not Allowed (http: // localhost)

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, and the following Error occurs: Error * Can't connect to host ''localhost'': the target machine actively rejects the request, unable to connect. 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.

Article Source: http://www.diybl.com/course/1_web/webjs/2008410/109655_2.html

Http://hi.baidu.com/yuncsoft/blog/item/19b41d5168e4a81c377abed6.html
After installing the svn server, you must add a service item in windows to facilitate startup.
We have completed this step using batch processing. Note that you can only delete it from the registry after adding it. If you know other methods, please leave a message. Grateful.

SC create svnserver binpath = "C: \ Program Files \ Subversion \ bin \ svnserve.exe -- service -- root F: \ svn "displayname =" svnserver "depend = tcpip start = auto obj =" nt authority \ NetworkService"
C: \ Program Files \ Subversion \ bin \ svnserve.exe is the svn path.
F: \ svn is the version library directory
Displayname = "svnserver" is used to set the service name.
-- Root is used to set the root directory, for example: svn: // localhost/svn
When setting -- root F: \ svn, it must be abbreviated as svn: // localhost. Otherwise, Error: URL 'svn: // localhost/svn 'doesn' t exist

Automatically update the Configuration:

During development, you often need to update the WEB server while updating SVN. Subversion hooks can be used for implementation.

The configuration in Windows is as follows:

Create a new post-commit.bat file under the hooks directory of the SVN repository, open it with notepad, and write the following code:

@ Echo off

Set repos = % 1
Set rev = % 2

Set dir = % REPOS %/hooks
Set path = % PATH %;

SET WORKING_COPY = D: \ Websites \ Latisse
Svn update % WORKING_COPY %-username user-password pwd

Here, D: \ Websites \ Latisse is the directory of the WEB site (of course, you must first create this directory and check out the corresponding project from the svn server ).

After the user submits the request, it is automatically updated to the WEB server.

Note that the problem is:

1. Do not modify or perform other operations in the WEB site folder to prevent the folder from being locked. Cannot be updated.

2. Here I have clearly stated the user name and password (pwd ). When I set it, I found that if it is not set, an error will occur. It can be executed normally when the bat file is directly run, but it cannot run normally after Subversion is submitted. In addition, we can see that there will be cmd and svn processes in the server process, and they will not end on their own. However, after the user submits the content to the server, the client will not be able to return normally.

3. If the operation fails, you can see the error information in the following method:

Rename the post-commit.bat just now to the post-commit-run.bat, and then create a post-commit.bat file, which writes the following code:

Call % ~ Dp0post-commit-run.bat % *> % 1/hooks/post-commit.log 2> & 1

In this way, the running result is written to the post-commit.log file, and if there is an error, you can also find the cause of the error.

After the svn server changes the ip address, the client can be located again:
Use TortoiseSVN of the latest version, right-click the root directory of the working copy, right-click TortoiseSVN, and click Relocate .. but we 'd better back up the data first .. this operation is dangerous.

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.