Step-sharing (Subversion) _win server on the SVN server side of Windows

Source: Internet
Author: User
Tags http authentication parent directory rfc subversion client svn svn update win32 tortoisesvn
1. Get SVN program

2, install Subversion (hereinafter referred to as SVN) server side and client. Download the server side is a ZIP compression package, direct decompression can be, such as I extract to E:\subversion. Client installation file is an EXE executable file, directly run the prompt installation can be installed, the client after installation prompts restart.

3, first set up an empty directory E:\SVN\REPOS1, attention must be empty. Then, on the Repos1 folder, right-click->tortoisesvn->create Repository here ..., and then you can select the version library mode, which uses the default FSFS, and then creates a series of folders and files. Same as the command line.
(This step notes that the SVN server is under the same letter as the Library directory, or that the directory is not 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 a daemon so that it does not exit until the manual termination. Note Do not close the command line window, close the window will stop the 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
To
Password-db = passwd

That is, remove the previous # annotation and note that there is no space in front of it.
Then modify the passwd file in the same directory and add an account number:

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

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

6, initialization of the import

(You must perform step 5th before doing this step)
The following is the import of our data (project) into this version library, and later the version library to manage our data. Any changes we make are recorded back to the version library, and even when we lose or change the data, the library can help us retrieve the data.
For example, I have a guestbook folder under the D:\wwwroot, which is stored in the Guest book Program I wrote. On this folder, right-click-> tortoisesvn-> Import ..., enter "Svn://localhost/repos1/guestbook" in the "URL of Repository" pop-up dialog box. Enter "Import entire guest book" as a comment in the import message.
Click OK to enter the account number after the request. We enter test in username and password. When finished, the contents of the guestbook are all imported into the Svn://localhost/svn/repo1/guestbook.
We see no change in E:\SVN\REPO1, even a guestbook folder is not established, the only change is the E:\SVN\REPO1 capacity of the larger. In fact, the contents of our source guestbook have been imported into the REPO1 version library, and the source guestbook folder can be deleted.

7, SVN configuration end, this is the simplest step, has been used, and then the SVN integration to the system services, the future 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 " Svnserver "depend= tcpip start= auto obj=" NT AUTHORITY\NetworkService "
Where C:\Program Files\subversion\bin\svnserve.exe is the SVN path
F:\SVN is a catalog of version libraries
Displayname= "Svnserver" for setting the name of the service
--root is to set the root directory for example: Originally 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 data, a little tidy up a bit, if the above content can not be satisfied, refer to the following content, I hope not to waste valuable time. 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, preparatory work
1. Get Subversion Server program
Download the latest server Installer to the official website (http://subversion.tigris.org/). Currently the latest is 1.4.6 version, the specific download address in: Http://subversion.tigris.org/ser ... 100&folderid=91, note 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 program used to communicate with the Subversion server side. Subversion takes a client-side program Svn.exe, but TortoiseSVN better operation and improve efficiency.

Second, install server side and client
First installs Apache 2.2.6, the concrete installation method everybody consults the related material, or see I write "Installs Apache 2.2.x under the Windows".
Second, install the server-side and the client of Subversion (hereinafter referred to as SVN). Download the server side is a ZIP compression package, direct decompression can be, such as I extract to E:\subversion. Client installation file is an EXE executable file, directly run the prompt installation can be installed, the client after installation prompts restart.

Iii. build version library (Repository)
Running a subversion server requires that you first establish a version library (Repository). A version library can be viewed as a place where data is centrally stored and managed on the server.
Start building a version library. First establish the E:\SVN empty folder as the root of all version libraries. 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 version library repos1 under E:\SVN. Repos1 some folders and files are automatically generated below.

We can also use TORTOISESVN graphically to complete this step:
First set up empty directory E:\SVN\REPOS1, note must be empty. Then, on the Repos1 folder, right-click->tortoisesvn->create Repository here ..., and then you can select the version library mode, which uses the default FSFS, and then creates a series of folders and files. Same as the command line.

four, run Independent server
At this point, the Subversion service has not yet started, only through its command to establish a version library. 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 a daemon so that it does not exit until the manual termination. Note Do not close the command line window, close the window will stop the Svnserve.

To verify that Svnserve is working properly, use the 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 see the REPO1 version of the Library directory tree structure, only then REPO1 is an empty library.

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

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

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

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

The version library 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

To
Password-db = passwd

That is, remove the previous # annotation and note that there is no space in front of it.
Then modify the passwd file in the same directory and add an account number:

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

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

Vi. Initialization of the import
The following is the import of our data (project) into this version library, and later the version library to manage our data. Any changes we make are recorded back to the version library, and even when we lose or change the data, the library can help us retrieve the data.
For example, I have a guestbook folder under the D:\wwwroot, which is stored in the Guest book Program I wrote. On this folder, right-click-> tortoisesvn-> Import ..., enter "Svn://localhost/repos1/guestbook" in the "URL of Repository" pop-up dialog box. Enter "Import entire guest book" as a comment in the import message.
Click OK to enter the account number after the request. We enter test in username and password. When finished, the contents of the guestbook are all imported into the Svn://localhost/svn/repo1/guestbook.
We see no change in E:\SVN\REPO1, even a guestbook folder is not established, the only change is the E:\SVN\REPO1 capacity of the larger. In fact, the contents of our source guestbook have been imported into the REPO1 version library, and the source guestbook folder can be deleted.

It should be noted that this step can be done entirely on another client with TORTOISESVN installed. For example, the IP of the host running Svnserve is 133.96.121.22, then the content of the URL part is "svn://133.96.121.22".


VII. Basic Operating Procedures
1. Remove (check out)
To remove a version library to a working copy:
Come 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 that we get a working copy of the content in guestbook.

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

On the modified file "right button-> tortoisesvn-> show Log", you can see all the submissions on this file. "Right-click-> Compare with Working copy" on a different revision entry allows us to compare the difference between a working copy file and a selected revision version.



To Install the APACHESVN Server tutorial:

Subversion's design includes an abstract network layer, which means that the version library can be accessed through a variety of server processes. In theory, subversion can be implemented with an unlimited number of network protocols, and there are currently two kinds of servers in practice.
? Svnserver:svnserve is a small (also called lightweight), stand-alone server that uses its own defined protocols and clients. (Author Note: This server is called the "Svnserver server" and the installation configuration above is the installation of the Svnserver server.) )
? Apachesvn:apache is the most popular Web server, and by using the MOD_DAV_SVN module, Apache can access the version library and enable clients to access it using the HTTP extension protocol Webdav/deltav. (Author Note: This server is called "APACHESVN server" below)

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

Because Subversion requires versioning, the standard Http protocol does not meet the requirements. For Apache to work in conjunction 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 the specification and working principle of WebDAV can be referenced in the IETF RFC 2518 (http://www.ietf.org/rfc/rfc2518.txt).

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

1, configure good httpd 2.2.x, and start using Mod_dav.
2. Install MOD_DAV_SVN plugin for Mod_dav.
3, configure your httpd.conf, so that the HTTP protocol can access the version library.

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, the installation
1. Install Apache
The specific installation method see: "Install Apache 2.2.x under Windows"

2. Install Subversion
Will download down the Svn-win32-1.4.6.zip directly decompression can, for example, I extract to e:\subversion.
Copy Intl3_svn.dll, Libdb44.dll, mod_authz_svn.so, mod_dav_svn.so to the Apache module directory from the bin subdirectory of the Subversion installation 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 into:
LoadModule Dav_module modules/mod_dav.so

That is, remove the front "#" number.

Add to:
LoadModule Dav_svn_module modules/mod_dav_svn.so

Make sure it's after Mod_dav.

Now you've set up Apache and subversion, but Apache doesn't know how to handle subversion clients, such as TORTOISESVN. In order for Apache to know which directory is used as a 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 that you first need to enable Dav_module and then load Dav_svn_module. The external URL of the version library is: http://server ip/repository, all the Subversion version libraries are physically located in E:/svn/repos1.
After the configuration is completed, restart Apache, open the browser, enter the http://server ip/repository will see the following screen:


This means that the DAV_SVN module of Apache is working properly. Users can access your version library through the HTTP protocol using any kind of Subversion client.

If you want to specify more than one version library, you can use more than one Location label, or you can use Svnparentpath instead of Svnpath, for example, there are multiple versions of the library Repos1,repos2, and so on, as specified in the following manner:

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

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

Your version library is now accessible to anyone and has full write permission. That is, anyone can read, modify, submit, and delete the contents of the version library 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 E:\subversion\bin\ Svnserve.exe. Because the submission is handled via the Apache DAV module, not by Svnservice. )。 We know by using TORTOISESVN client authentication.
Obviously most of the occasions this is not in line with demand. So how do you set the permissions, Apache provides the basic permissions settings:

Four, authentication option
1. Basic HTTP Authentication
The simplest method of client authentication is to authenticate a user by using the HTTP Basic authentication mechanism, and simply use the username and password. Apache provides a HTPASSWD tool to manage a user file that contains user names and encrypted passwords, which you want to give the Subversion special privileges to. HTPASSWD can be found in the Apache Bin installation directory. The specific use of the following methods:

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

Add new User (-m to MD5 encrypted password):
htpasswd [m]/etc/svn/passwordfile Newusername

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

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


Next, modify httpd.conf and add the following in the Location tag:

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

Description
AuthType Basic: Enable Basic 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 installation language packs.) )
AuthUserFile e:/usr/apache2.2/bin/passwd: Specifies E:\usr\Apache2.2\bin\passwd as a user file to authenticate the user's username and password.
Require valid-user: Restrict users to access this path only if they have entered the correct username and password

Restart Apache and open the browser to access the version library. Apache will prompt you to enter your username and password to authenticate the login, and now only users in the passwd file can access the version library. You can also configure only specific users to be able to access, replacing the above "Require Valid-user" as "Require user Tony Robert" will only have user files in which Tony and Robert can access that version of the library.

Sometimes you may not need such strict access control, for example, most open source projects allow anonymous read operations, and only authenticated users allow write operations. To achieve more granular authorization, you can use the Limit and limitexcept tags. For example:

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

The above configuration will give anonymous users read access, and restrict only those users configured in passwd to use write operations.
If this does not meet your requirements, you want accurate control of the version Library directory access, you can use the Apache MOD_AUTHZ_SVN module for each directory authentication operation.

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 and 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 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 is pointing to the Authz policy file, which can be specified in the policy file with detailed permission controls. The syntax for accessing the file accesspolicy.conf is very similar to the svnserve.conf and Apache configuration files, and the rows beginning with (#) are ignored; In its simple form, each section names a version library and a path inside. The authenticated user name is the option name in each subsection; the value of each option describes the level at which the user accesses the version library: R (read-only) or RW (read-write), which is not allowed if the user does not mention it, or if the value is left blank; * represents all users, using 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 versions of libraries, all of the version libraries are 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 versions of the library. If you want to configure each version of the library, 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

Such a repos1 project1_committer group can only write permissions to files under the REPOS1 version Library and cannot modify the version library Repos2, and REPOS2 groups Project2_commiter also cannot modify files in REPOS1 version libraries.



FAQ:

1. Error message prompts when path or insufficient permissions are present:

http://localhost (incorrect path)
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 (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, access (tortoisesvn–> Repo–browser) or submit (SVN commit) as follows:

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

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

SC create svnserver binpath= "C:\Program files\subversion\bin\svnserve.exe--service--root" F:\SVN " Svnserver "depend= tcpip start= auto obj=" NT AUTHORITY\NetworkService "
Where C:\Program Files\subversion\bin\svnserve.exe is the SVN path
F:\SVN is a catalog of version libraries
Displayname= "Svnserver" for setting the name of the service
--root is to set the root directory for example: Originally 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 your Web server while you are updating SVN. Can be achieved with a subversion hook (hook).

The following are the configurations under the Windows operating system:

Create a new Post-commit.bat file under the Hooks directory in the SVN library, open it in 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 (the directory must be built first and the corresponding project checked out from the SVN server).

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

The issues to be noted are:

1. Do not modify the Web site folder or other actions to prevent the folder from being locked. cannot be updated.

2. I have explicitly stated the username (user), password (PWD). When I set it up, I found that if there were no settings, there would be an error, which would normally be performed when the bat file was run directly, but it would not work correctly after subversion was committed. You can see that the CMD,SVN two processes appear in the server process and do not end up on your own, and that the client does not return correctly after submitting content to the server.

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

Rename the Post-commit.bat to Post-commit-run.bat, and then build a Post-commit.bat file that writes 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 if there is an error, the cause of the error can be found.


Client Relocation method After the SVN server changes IP:
With the latest version of TortoiseSVN, right-click on the root directory of the working copy->tortoisesvn-> reposition (relocate), and then follow the prompts to operate it. However, it is best to back up first. Because there's a certain danger to this operation.
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.