Build SVN server-side step sharing under Windows (Subversion)

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

1. Get SVN program

2, install Subversion (hereinafter referred to as SVN) server side and client. Download down the server side is a ZIP compression package, direct decompression can, for example, I extracted to E:\subversion. The client installation file is an EXE executable file, run as prompt to install, the client after the installation is completed prompt restart.

3, first set up empty directory E:\SVN\REPOS1, attention must be empty. Then on the Repos1 folder "right->tortoisesvn->create Repository here ...", then you can choose the repository mode, where the default Fsfs is used, and a series of folders and files are created. Same as the command line.
(This step is to note that the SVN server and the library directory under the same drive letter, otherwise the directory cannot be found)

4. Go to the command line and switch to the Subversion bin directory. Enter the following command:

Svnserve.exe--daemon

Svnserve will wait for the request on Port 3690, and the--daemon (two dash) option tells Svnserve to run as daemon so that it does not exit until it is manually terminated. Be careful not to close the command line window, close the window will stop Svnserve

5. Configure Users and Permissions
Open the E:\svn\repos1\conf directory with a text editor and modify the svnserve.conf:
Will:
# password-db = passwd
Switch
Password-db = passwd

That is, remove the previous # comment and note that there must be no spaces ahead.
Then modify the passwd file of the same directory and add an account number:

Will:
[Users]
# Harry = Harryssecret
# sally = Sallyssecret

Add Account:
[Users]
#harry = Harryssecret
#sally = Sallyssecret
Test = Test

6. Initialize the Import

(Be sure to perform step 5th before doing this)
Here's how to import our data (project) into this repository and later manage our data from the repository. Any changes we make are recorded in the repository, and even our own repositories can help us retrieve the data when we lose it or change the data incorrectly.
For example, I have a guestbook folder under the D:\wwwroot, which is stored in the guestbook program I wrote. On this folder, "Right click-TortoiseSVN, Import ...", enter "Svn://localhost/repos1/guestbook" in the "URL of repository" of the popup dialog box. Enter "Import entire guest book" as a comment in the "import message".
After you click OK, you need to enter your account. We enter test at the user name and password. When you are finished, the contents of guestbook are all imported into the Svn://localhost/svn/repo1/guestbook.
We see no change in the E:\SVN\REPO1, even a guestbook folder is not established, the only change is the E:\SVN\REPO1 capacity has become larger. In fact, the contents of our source guestbook have been imported into the REPO1 repository, and the source guestbook folder can be deleted.

7, SVN configuration end, this is the simplest step, already can use, and then the SVN integration into the system services, will not have to open the Command window. Paste the following into a text file, and then rename the file as: *.bat execution is good,
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 "
Where C:\Program Files\subversion\bin\svnserve.exe is the path to SVN
F:\SVN Directory for Repository
Displayname= "Svnserver" to set the name of the service
--root is to set the root directory such as: The original you visit as: SVN://LOCALHOST/SVN
Set--root F:\SVN after the abbreviation for Svn://localhost This must be noted, otherwise error:url ' svn://localhost/svn ' doesn ' t exist

8, SVN can use, the following is the original information, a little to tidy up a bit, if the above content can not be satisfied, reference the following content, hope that no valuable time wasted. If you want the site to be updated synchronously, use the hook program, also in the following content.

subvision SVN (SVN server-side) installation Tutorial:
First, the preparatory work
1. Get the Subversion server program
Download the latest server Installer to the official website (http://subversion.tigris.org/). Currently the latest is 1.4.6 version, specific in: Http://subversion.tigris.org/ser ... 100&folderid=91, look for the for Apache 2.2.x version.

2. Get TortoiseSVN client program
Get the latest tortoisesvn from the official website Http://tortoisesvn.net/downloads. TortoiseSVN is a client-side program used to communicate with Subversion server. Subversion comes with a client-side program Svn.exe, but TortoiseSVN is better to operate and improve efficiency.

Second, install the server side and the client
First install Apache 2.2.6, the specific installation method you refer to the relevant information, or I wrote the "installation of Apache 2.2.x under Windows."
Second, install Subversion (hereinafter referred to as SVN) server side and client. Download down the server side is a ZIP compression package, direct decompression can, for example, I extracted to E:\subversion. The client installation file is an EXE executable file, run as prompt to install, the client after the installation is completed prompt restart.

Third, build the Repository (Repository)
Running the Subversion server requires that you first build a repository (Repository). Repositories can be seen as places where data is centrally stored and managed on the server.
Start building the repository. Start by establishing the E:\SVN empty folder as the root directory for all repository. Then, go to the command line and switch to the Subversion bin directory. Enter the following command:

Svnadmin Create E:\svn\repos1

This command establishes a repository repos1 under E:\SVN. Repos1 some folders and files are automatically generated below.

We can also use TortoiseSVN to graphically complete this step:
First set up empty directory E:\SVN\REPOS1, notice must be empty. Then on the Repos1 folder "right->tortoisesvn->create Repository here ...", then you can choose the repository mode, where the default Fsfs is used, and a series of folders and files are created. Same as the command line.

Iv. running a standalone server
At this point, the Subversion service has not yet started, only through its command to build the repository. Continue typing in the command window just now:

Svnserve.exe–daemon

Svnserve will wait for the request on Port 3690, and the--daemon (two dash) option tells Svnserve to run as daemon so that it does not exit until it is manually terminated. Be careful not to close the command-line window, and closing the window will stop Svnserve.

To verify that Svnserve is working correctly, use TORTOISESVN-repo-browser to view the repository. In the Popup URL dialog box, enter:

Svn://localhost/svn/repo1

Click OK button to see the REPO1 repository of the directory tree structure, only then REPO1 is an empty library.

You can also use the--root option to set the root location to restrict the server's access to the directory, thereby increasing security and saving time for entering the Svnserve URL:

Svnserve.exe--daemon--root drive:\path\to\repository

Taking the previous test as an example, Svnserve will run as:

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

The Repository browser URL in TortoiseSVN is then reduced to:

Svn://localhost/repo1

v. Configuring Users and Permissions
Open the E:\svn\repos1\conf directory with a text editor and modify the svnserve.conf:
Will:
# password-db = passwd

Switch
Password-db = passwd

That is, remove the previous # comment and note that there must be no spaces ahead.
Then modify the passwd file of the same directory and add an account number:

Will:
[Users]
# Harry = Harryssecret
# sally = Sallyssecret

Add Account:
[Users]
#harry = Harryssecret
#sally = Sallyssecret
Test = Test

Vi. initializing the import
Here's how to import our data (project) into this repository and later manage our data from the repository. Any changes we make are recorded in the repository, and even our own repositories can help us retrieve the data when we lose it or change the data incorrectly.
For example, I have a guestbook folder under the D:\wwwroot, which is stored in the guestbook program I wrote. On this folder, "Right click-TortoiseSVN, Import ...", enter "Svn://localhost/repos1/guestbook" in the "URL of repository" of the popup dialog box. Enter "Import entire guest book" as a comment in the "import message".
After you click OK, you need to enter your account. We enter test at the user name and password. When you are finished, the contents of guestbook are all imported into the Svn://localhost/svn/repo1/guestbook.
We see no change in the E:\SVN\REPO1, even a guestbook folder is not established, the only change is the E:\SVN\REPO1 capacity has become larger. In fact, the contents of our source guestbook have been imported into the REPO1 repository, and the source guestbook folder can be deleted.

It is important to note that this step can be done entirely on another client computer with TortoiseSVN installed. For example, the IP of the host running Svnserve is 133.96.121.22, and the URL part of the input is "svn://133.96.121.22".


VII. Basic Operating Procedures
1. Remove (check out)
Remove Repository to a working copy:
To any empty directory, such as creating an empty folder F:\work in the F partition. "Right-click SVN Checkout". Enter "Svn://localhost/svn/repo1/guestbook" in "URL of repository" so we get a working copy of the content in the guestbook.

2. Deposit (check in)/Submit (Commit)
Make changes in the working copy and submit:
Open a file in a guestbook working copy, make changes, and then "right-click SVN Commit ... ”。 This allows us to submit the changes to the repository, and the repository stores the data we submit, as appropriate.

On the modified file, "right-TortoiseSVN, Show Log", you can see all the commits to this file. On the different revision entries, right-Compare with working copy, we can compare the difference between the working copy file and the selected revision version.



To Install the APACHESVN Server tutorial:

Subversion is designed to include an abstract network layer, which means that the repository can be accessed through various server processes. In theory, subversion can be implemented with an unlimited number of network protocols, and there are two kinds of servers in practice.
? Svnserver:svnserve is a small (also called lightweight), standalone server that uses its own defined protocols and clients. (Author Note: This server is called "Svnserver Server", the above installation configuration is to install the Svnserver server.) )
? Apachesvn:apache is the most popular Web server, and by using the MOD_DAV_SVN module, Apache has access to the repository and can be accessed by the client using the Extended protocol Webdav/deltav for HTTP. (The author note: This server is called "APACHESVN server")

Access to the repository via the Http protocol is one of the highlights of Subversion. APACHESVN servers have many features that svnserve servers do not have, and are more flexible to use, but a bit difficult to configure, and flexibility often brings complexity.

Because Subversion requires versioned control, the standard Http protocol does not meet the requirements. For Apache to work with Subversion, you need to use WebDAV (web-based distributed Authoring and Versioning:) Web Distributed Authoring and Versioning). WebDAV is an extension of HTTP 1.1, and you can refer to IETF RFC 2518 (http://www.ietf.org/rfc/rfc2518.txt) for the specification and working principles of WebDAV.

First, the necessary conditions
In order for your repository to use the HTTP network, you must have the following conditions:

1, configure the httpd 2.2.x, and use Mod_dav to start.
2, install MOD_DAV_SVN plug-in for Mod_dav.
3. Configure your httpd.conf so that the HTTP protocol can access the repository.

The following is explained in detail in my configuration process.

Environment:
Os:windows XP SP2
Web:apache 2.2.6
svn:svn-win32-1.4.6

Second, installation
1. Installing Apache
Specific installation methods see: "Install Apache 2.2.x under Windows"

2. Install Subversion
The downloaded svn-win32-1.4.6.zip can be extracted directly, such as I extract to e:\subversion.
Copy the Intl3_svn.dll, Libdb44.dll, mod_authz_svn.so, mod_dav_svn.so from the bin subdirectory of the Subversion installation directory to the Apache module directory (Apache installation directory Modules folder).

Three, basic Apache configuration
Modify the Apache configuration file httpd.conf and use LoadModule to load the MOD_DAV_SVN module.

Will
#LoadModule Dav_module modules/mod_dav.so

Change to:
LoadModule Dav_module modules/mod_dav.so

That is, remove the "#" from the front.

Add to:
LoadModule Dav_svn_module modules/mod_dav_svn.so

Make sure it's behind Mod_dav.

Now that you've set up Apache and subversion, Apache doesn't know how to handle subversion clients, such as TORTOISESVN. In order for Apache to know which directory is used as the Subversion repository, you need to edit the Apache configuration file using an editor such as Notepad.

At the end of the configuration file, add the following lines:

<Location/repository>
DAV svn<


br/> Svnpath e:/svn/repos1
</Location>

This configuration tells Apache to first need to enable Dav_module and then load Dav_svn_module. The Repository external URL is:/HTTP server ip/repository, all Subversion repository is physically located in E:/svn/repos1.
After the configuration is complete, restart Apache, open the browser, enter http://server ip/repository will see the following screen.


This means that Apache's DAV_SVN module is ready to function. Users can use any kind of Subversion client to access your repository via the Http protocol.

If you want to specify more than one repository, you can use multiple location tags or svnparentpath instead of svnpath, such as having multiple repository repos1,repos2 under E:\SVN, and so on, as specified in the following ways:

<Location/repository>
DAV SVN
Svnparentpath E:/SVN
</Location>

"Svnparentpath e:/svn" means that each subdirectory under E:\SVN is a repository. can be accessed via http:/server ip/repository/repos1,http://server Ip/repository/repos2.

Now anyone in your repository can access it and have full write permissions. This means that anyone can read, modify, commit, and delete content from the repository anonymously (note: You do not need to configure the E:\svn\repos\conf\svnserve.conf file at this time, and you do not need to start the E:\subversion\bin\ Svnserve.exe. Because the submission is handled by Apache's DAV module, not by Svnservice. )。 We use the TortoiseSVN client to verify that it is known.
Obviously, most of the occasions this is not in line with demand. So how to set the permissions, Apache provides the basic permission settings:

IV. Certification Options
1. Basic HTTP Authentication
The simplest way to authenticate a client is through the HTTP Basic authentication mechanism, which simply uses the user name and password to verify the identity of a user. Apache provides a HTPASSWD tool to manage a user file that contains user names and encrypted passwords, which are the users you want to give special privileges to Subversion. The htpasswd can be found under the Apache Bin installation directory. Here's how to use it:

To create a user file:
Htpasswd-c/etc/svn/passwordfile username

Add a new user (-m means to encrypt the password with MD5):
htpasswd [-m]/etc/svn/passwordfile Newusername

change user password:
htpasswd [-m]/etc/svn/passwordfile username

Delete the user (to use uppercase D):
Htpasswd–d/etc/svn/passwordfile username


Next, modify the httpd.conf to include the following in the Location tab:

AuthType Basic
AuthName "SVN repos"
AuthUserFile e:/usr/apache2.2/bin/passwd
Require Valid-user

Description
AuthType Basic: Enables fundamental authentication, such as username/password pairs.
AuthName "SVN repos": Information that appears in the authentication dialog box when an authentication dialog box pops up. (preferably in English, TortoiseSVN does not support Chinese, except for the installation of language packs.) )
AuthUserFile e:/usr/apache2.2/bin/passwd: Specifies that E:\USR\APACHE2.2\BIN\PASSWD is the user file that is used to authenticate the user's 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 the browser to access the repository. Apache will prompt you to enter a username and password to authenticate the login, now only the users set in the passwd file can access the repository. You can also configure only specific users to be able to access, replacing the above "Require Valid-user" as "Require user Tony Robert" will have access to the repository only for Tony and Robert in the user files.

Sometimes it may not be necessary to have such strict access controls, for example, most open source projects allow anonymous read operations, and only authenticated users allow write operations. For more granular permission authentication, you can use the Limit and limitexcept tags. For example:

<limitexcept GET PROPFIND OPTIONS report>
Require Valid-user
</LimitExcept>

The above configuration will allow anonymous users to have read permissions, and only users who are configured in passwd can use write operations.
If this does not meet your requirements, you want to control the repository directory access accurately, you can use the Apache MOD_AUTHZ_SVN module to authenticate each directory.

2. Using MOD_AUTHZ_SVN for Directory access control
First you need to have Apache load the MOD_AUTHZ_SVN module in. Locate 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 to add:

LoadModule Authz_svn_module modules/mod_authz_svn.so

You can now use the Authz feature in the Location tab. 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 points to the Authz policy file, and the detailed permission control can be specified in this policy file. The syntax for accessing the file accesspolicy.conf is very similar to the svnserve.conf and Apache configuration files, and the lines beginning with (#) are ignored; In its simple form, each section names a repository and a path inside. The authentication user name is the option name in each section, and the value of each option describes the level at which the user accesses the repository: R (read-only) or RW (read-write), which is not allowed if the user is not mentioned or the value is left blank; * Indicates that all users use it to control the access rights of anonymous users; Such as:

[Groups]
Committers = Paulex, Richard
Developers = Jimmy, Michel, Spark, Sean

[/]
* = R
@committers = RW

[/branches/dev]
@developers = RW

[/tags]
Tony = RW
[/private]
* =
@committers = R

When you use Svnparentpath instead of Svnpath to specify the parent directory for multiple repositories, all of the repositories will be configured according to this policy file. For example, in the example above, Tony will have read and write access to the/tags directory in all repositories. If you want to configure each repository, use the following syntax:

[Groups]
Project1_committers = Paulex, Richard
Project2_committers = Jimmy, Michel, Spark, Tony, Robert

[repos1:/]
* = R
@ project1_committer = RW

[repos2:/]
* = R
@ project2_committer = RW

This way, the REPOS1 project1_committer group can only write permissions to files under the REPOS1 repository and cannot modify the repository Repos2, and repos2 groups of Project2_commiter cannot modify the REPOS1 repository files.



FAQ:

1, path or insufficient permissions will appear error message prompt:

http://localhost (path not correct)
Error * PROPFIND request failed on '/' PROPFIND of '/': $ 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 (normal display)

Http://localhost/repos (Permissions 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 started the APACHESVN, Access (tortoisesvn–> Repo–browser) or submit (SVN commit) scenario is as follows:

Symptom: Svn://localhost/svn/repos cannot access or commit, prompt: Error * can ' t connect to host ' localhost ': unable to connect due to active rejection of target machine. But File:///e:/svn/repos and http://localhost/svn/repos can be accessed or submitted.

Cause: svn://is a standalone server svnserver its own protocol. file:///is a local access, that is, the server side and the client on a 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 the service entry under Windows for easy startup
We use batch processing to complete, do this step to note that after adding can only be removed from the registry, if you know other ways please leave a message. Appreciate.

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 "
Where C:\Program Files\subversion\bin\svnserve.exe is the path to SVN
F:\SVN Directory for Repository
Displayname= "Svnserver" to set the name of the service
--root is to set the root directory such as: The original you visit as: SVN://LOCALHOST/SVN
Set--root F:\SVN after the abbreviation for Svn://localhost This must be noted, otherwise error:url ' svn://localhost/svn ' doesn ' t exist

Auto-Updated configuration:

In development, you often update the Web server while you update SVN. Can be done with subversion hooks.

The following are the configurations under the Windows operating system:

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

The D:\Websites\Latisse here is the directory of the Web site (which, of course, has to be built first and checked out from the SVN server).

This will automatically update to the Web server when the user has finished submitting it.

It is important to note that the problem is:

1. Do not modify or otherwise manipulate the Web site folder to prevent folders from being locked. cannot be updated.

2. Here I explicitly specify the username (user), password (PWD). When I set up, I found that if there is no setting, there will be an error, when running the bat file can be executed normally, but after subversion is committed, it does not work properly. And you can see that the server process will appear cmd,svn two processes, and will not end itself, and users after the submission of content to the server, the client will not return the normal problem.

3. If the operation is not normal, you can see the error message by the following method:

Rename the Post-commit.bat to Post-commit-run.bat, and then build a Post-commit.bat file with the following code:

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

The result is written to the Post-commit.log file, and the cause of the error can be found if there is an error.


After the SVN server changes the IP, the client repositions the method:
With the latest version of TortoiseSVN, right-click on the root of the working copy to->tortoisesvn-> reposition (relocate), and then follow the prompts to do it. But it's best to back it up first. Because this operation has a certain danger.

Build SVN server-side step sharing under Windows (Subversion)

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.