How to Build SVN servers in Windows (apache)

Source: Internet
Author: User
Tags tortoisesvn

This section describes how to set up the SVN server in Windows. Here, we will share with you some suggestions and hope they will be useful to you.

1. Software Download

Set up the SVN server in Windows and download the Subversion server program. Go to the official website to download the binary Installation File, go to the Binary Package download section, find WindowsNT, 2000, XPand2003, and then select "thisdirectory". In this example, we can see more content. Currently, we can download svn-1.4.0-setup.exe. Download the Subversion of the Windows client TortoiseSVN. TortoiseSVN is a tool used to expand Windows shell. It can be seen as a plug-in for Windows resource manager. After installation, Windows can identify the working directory of Subversion. The official website is TortoiseSVN, the Download method is similar to the svn server in front, in the Download page we can choose to Download the version, the current maximum stable version of the installation file for the TortoiseSVN-1.4.0.7501-win32-svn-1.4.0.msi.

2. server and client Installation

In Windows, when the svnserver is built, the server is installed and svn-1.4.0-setup.exe is run directly. Install svn-1.4.0-setup.exe as prompted. In this way, we have a server running environment. Install TortoiseSVN, also directly run the TortoiseSVN-1.4.0.7501-win32-svn-1.4.0.msi according to the prompts to install, but after the completion of the last will prompt whether to restart, in fact, restart is just to make svn work copy in the special style of windows effective, it has nothing to do with all the actual functions. In order to immediately see the good results, restart the machine.

3. Create a version Library (Repository)

To run the Subversion server, you must first create a version Library (Repository), which can be seen as a database for storing data on the server. After the Subversion server is installed, you can run it directly, for example: svnadmincreateE: \ svndemo \ repository creates a version library under the directory E: \ svndemo \ repository. We can also use TortoiseSVN to perform this step graphically: Right-click the directory E: \ svndemo \ repository and choose TortoiseSVN> CreateRepositoryhere... ", then you can select the version library mode. Here you can use the default mode, and then create a series of directories and files.

4. Configure users and permissions

To build the SVN server in Windows, go to the E: \ svndemo \ repository \ conf directory and modify svnserve. conf:Copy codeThe Code is as follows: # [general]
# Password-db = passwd
Changed:
[General]
Password-db = passwd, modify the passwd file in the same directory, and remove the following three lines of comment:
# [Users]
# Harry = harryssecret
# Sally = sallyssecret
Finally changed:
[Users]
Harry = harryssecret
Sally = sallyssecret

5. Run the independent server

Run svnserve-d-rE: \ svndemo \ repository in any directory and our server program will be started. Do not close the command line window. Close the window will also stop svnserve.
Run sccreatesvnservicebinPath = "D: \ ProgramFiles \ Subversion \ bin \ svnserve.exe -- service-rE: \ SVN" DisplayName = "SvnService" depend = Tcpipstart = auto

6. initialize the Import

In Windows, the SVN server is set up and the project root directory we want to Import is E: \ svndemo \ initproject. the directory contains a readme.txt file: Right-click-> TortoiseSVN-> Import...
After URLofrepository input "svn: // localhost/" OK, the directory remains unchanged. If no error is reported, all the data has been imported to the version library we just defined.
Note that this step can be performed on another host 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 /".

Two methods to build a test server using SVN

This section describes how to use SVN to build a test server. There are two common methods, you are welcome to join me in learning how to build a test server using SVN.
In the formal team development process, server testing is an essential part. How to deploy the test server easily and quickly is the focus of this article. The actual environment in this article is CentOS + PHP + MySQL + SVN. Two different ways are used to deploy the test server. Let's take a look at the first way to build a test server using SVN.
First, post-commit
Post-commit itself is one of the SVN series hooks to facilitate the processing of Common Operations in SVN usage. The steps for establishing a test server are as follows:
In the hooks directory, create the post-commit file and define its content as similar to the following:Copy codeThe Code is as follows :#! /Bin/sh
ExportLANG = en_US.UTF-8
Svncheckout -- usernamekimi -- passwordpasswordsvn: // 10.0.0.8/projects // wwwroot/projects.ismole.net
Chownwww: www/wwwroot/projects.ismole.net-Rf

Note:
1 .#! /Bin/sh indicates that the shell command is executed.
2. exportLANG = en_US.UTF-8 is to solve svnpostcommit Chinese garbled characters and set localization encoding. However, SVN uses UTF-8 encoding by default. If the character set is correct and is not set, an error occurs, but the execution fails. The error code is svn: Can 'tconvertstringfromnativeencodingto 'utf-8 ′
3. svncheckout-usernamekimi-passwordpasswordsvn: // 10.0.0.8/projects // wwwroot/projects.ismole.net perform the SVN check-out operation
4. chownwww: www/wwwroot/projects.ismole.net-Rf change the folder owner to be suitable for WebServer.
All the original code in the file is commented out. You can run the shell command to call this file every time the commit is completed. Let's take a look at the second method of building a test server using SVN.
Second, PHP checks out SVN
Copy codeThe Code is as follows: <? Php
Header ("Cache-Control: no-cache, must-revalidate ");
$ Handle = popen ('svncheckout -- usernamekimi -- passwordpasswordsvn: // 10.0.0.8/projects // wwwroot/projects.ismole.net ', 'R ');
$ Read = stream_get_contents ($ handle );
Echo "<pre> ";
Printf ($ read );
Echo "</pre>"
Pclose ($ handle );
?>

In fact, this method only uses PHP to execute linux commands. See PHP monitoring linux server load: http://www.ccvita.com/390.html
The above two methods are implemented by checking out SVN and placing it in the corresponding web directory. In comparison, post-commit is simpler and faster, and requires no more operations. However, it has little permission control, as long as you have the SVN submission permission, you have the permission to deploy the test server. The PHP method is more troublesome, but the user permission control can be achieved by customizing the corresponding program, almost any role can control permissions.
In actual use, we currently adopt the first method for APP debugging and cooperative R & D. If SVN requires more permission control, we recommend the second method, it can cover testing, deployment, and launch. This remote development method is used in a cooperation with Sina. This section describes how to build a test server using SVN. For more information, see this section.

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.