Subvision SVN (SVN server) Installation tutorial

Source: Internet
Author: User
Tags http authentication subversion client tortoisesvn

 

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 E:/SVN/repo1 becomes larger. 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 in 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

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.