========================================================== ========================
This document is a reprinted document. You must ensure that the original author information and the link of this article are complete and complete.
E-mail:Khler@163.com
QQ: 23381103
MSN:Pragmac@hotmail.com
========================================================== ========================
Recently, a SVN server needs to be configured because of work requirements. After several experiments and reading a lot of information, the configuration is finally completed.
I have collected and sorted out some information on the Internet, and it is easy to waste valuable time. I have proved that the information is indeed available through my own practice. I also hope that you can complete the configuration quickly and smoothly.
I have configured Apache 2.2.9 + subversion1.5.3. Note the following:
1. Generally, you can enter an IP address in the browser to verify that Apache is working. For example, if my http: // 192.168.1.102/, "It works! "The page indicates that Apache is working properly. However, you will find that another machine in the same LAN cannot be accessed because the firewall blocks access. You can change Kaspersky (my own Kabbah varies from person to person) and Windows Firewall is disabled;
2. Restart Apache every time you change the httpd. conf file of Apache;
3. If your subversion is not an installed version, you must add the bin directory of subversion to the system environment variable of windows. For example, if my subversion is stored in c: \ Program Files \ subversion11.5.3, then I add the following path after the path entry of the system variable: C: \ Program Files \ subversion11.5.3 \ bin. After adding the service, you must restart it to make it effective.
--- Khler
2008.10.15
This article is based on CAI Yulin's articles, organized by airun and khler.
Abstract
This document provides a simple installation guide that describes how to install the Subversion server in a Windows environment and how to install the tortoisesvn client tool. All the operations mentioned in this article (except 2.6.2) have been verified in practice.
Contents
1 Overview
1.1 read Basic Concepts
1.2 environment and version
2. Install and create a Subversion server
2.1 install Apache HTTP Server
2.2 install Subversion
2.3 set the path of the Subversion file library
2.3.1 svnpath
2.3.2 svnparentpath
2.4 create a file library
2.5 introduce a project
2.5.1 file library and project configuration
2.5.2 project directory structure
2.6 Access Control
2.6.1 basic access control
2.6.2 sspi authentication Access Control (verify with a Windows domain account)
2.7 submit Control
2.7.1 restrict the submission of specific file types
2.7.2 force log-message input
2.7.3 a log-message modification method
3. Install the client tortoisesvn
3.1 install tortoisesvn
4 Conclusion
5 References
1 Overview
Subversion is a version control system. It is designed based on the features of CVS (Concurrent Versions System), but it improves the disadvantages of CVs, for example: it is inconvenient to move the file directory in CVS; in addition, it also adds other features, such as: an inseparable delivery (like the concept of database transactions, when sending multiple files, if any file fails, all the files sent this time will not enter the file library). Multiple network protocols and consistent file difference comparison are supported (no matter what file type, binary difference comparison is used.
The Subversion file found at hand is mainly for Linux users. Therefore, this file is specially designed for instructions on how to install subversion in windows, it helps you quickly install the subversion. If you are familiar with it, you can do it in an hour or two.
During the installation process, you will need to enter commands in some command columns. I will not explain in detail the usage and meaning of some commands. Therefore, you must be familiar with the basic commands of DOS, you should also check the Subversion e-books at any time (for example, the subverion script ") to learn how to use the subverion command tool. The graphical interface is convenient, but you are familiar with the use of command tools, so that you can be completely free.
1.1 read Basic Concepts
If you lack the basic concepts of the version control system, even if you have successfully installed the subversion, you may not know what to do next after the installation is complete. Here, we will only mention a few basic concepts. You will eventually have to read the official subversion file.
1.2 environment and version
The environment and version for installing subversion are as follows:
• Windows 2000 Server with SP4
• Apache HTTP Server: Apache_2.0.63-win32-x86-no_ssl.msi
• Sspi: mod_auth_sspi-1.0.2-2.0.54.zip
• Subversion: Setup-Subversion-1.5.1.en-us.msi
• Tortoisesvn: TortoiseSVN-1.4.0.7501-win32-svn-1.4.0.msi
2. Install and create a Subversion server
This section describes the steps required to install the subversion. Prepare a stable machine as the server of the subversion. The hard disk space should be as large as possible to avoid frequent server replacement due to insufficient disk space.
2.1 install Apache HTTP Server
Go to http://httpd.apache.org/download the installer for Apache HTTP Server 2.0 for Windows, and the file I downloaded is a Apache_2.0.63-win32-x86-no_ssl.msi.
Install IIS directly after downloading. The installation process is very simple and will not be described in detail. Before installation, check whether your computer has IIS installed. Because Apache uses 80 port by default, it will conflict with the IIS website, you must disable the IIS web platform and then install Apache HTTP server.
After the installation is complete, start Apache and open the browser. visit http: // 127.0.0.1/To see if the installation is successful. If the page displays "you can see this page, it indicates that Apache web server has been installed successfully. You can add content in this directory or replace this page ." The installation is successful.
For ease of description, we assume that Apache HTTP server is installed in the <apache_root> directory.
2.2 install Subversion
1. To http://subversion.tigris.org/download the latest version of the subversion, you can download. Zip or packaged automatic installer, I downloaded the Setup-Subversion-1.5.1.en-us.msi.
2. Install the SDK directly after the download. The installation process is the next step and there is nothing special about it. After the installation is complete, you can set the necessary environment variables (if you download the. ZIP file, you must set it yourself ). For ease of description, we assume that the Subversion is installed in the <subversion_root> directory.
3. Copy mod_dav_svn.so and mod_authz_svn.so in the <subversion_root>/bin/directory to the <apache_root>/modules/directory.
4. Copy libdb44.dll, libeay32.dll, and ssleay32.dll in the <subversion_root>/bin/directory to the bin or modules directory under <apache_root>.
5. Open Apache HTTP Server's <apache_root>/CONF/httpd. conf in the text editor, find a bunch of loadmodule commands, and find the following two lines:
# Loadmodule dav_module modules/mod_dav.so
# Loadmodule dav_fs_module modules/mod_dav_fs.so
Remove the '#' character at the beginning of the two lines, and then add the following line to the end of these loadmodule commands:
Loadmodule dav_svn_module modules/mod_dav_svn.so
Loadmodule authz_svn_module modules/mod_authz_svn.so
6. Restart Apache HTTP server.
Troubleshooting
If the Apache HTTP Server cannot be started, follow these steps:
1. Check whether the Subversion path is included in the system's % PATH % environment variable.
2. Check whether the project you added to httpd. conf is correct. Remember mod_dav_svn.so and mod_authz_svn.so.
It must be loaded after other mod_dav *. So modules.
2.3 set the path of the Subversion file library
Now you need to set the correspondence between the URL path and the actual path of the file library. There are two corresponding methods: svnpath and svnparentpath.
2.3.1 svnpath
Svnpath is suitable for specifying the path of the file library individually. Syntax:
<Location/SVN/repos_name>
Dav SVN
Svnpath/absolute/path/to/Repository
</Location>
"/SVN/repos_name" is the URI (Uniform Resource indentifier) used by the user to access a specific file library, and the path specified after svnpath is the absolute path of the file library, assume that the actual path of our file library is D:/SVN/myrepository, and you want the user to use the URL "http: // myserver/SVN/myrepos" to access the file library, add httpd. the conf content is:
<Location/SVN/myrepos>
Dav SVN
Svnpath D:/SVN/myrepository
</Location>
Note that the first slash of/SVN/myrepos after the location tag is indispensable!
2.3.2 svnparentpath
If your file library is concentrated under a directory such as D:/SVN, you can specify the root path of the file library using svnparentpath. Syntax:
<Location/SVN>
Dav SVN
Svnparentpath/absolute/path/to/Repository
</Location>
The path specified after svnparentpath is the absolute path of the file library. If the actual path of the file library is D:/SVN, the content to be added to httpd. conf is:
<Location/SVN>
Dav SVN
Svnparentpath D:/SVN
</Location>
This means that anyone can access all the file libraries in the Directory D:/SVN through http: // myserver/SVN/<file library name>. That is to say, this setting action only needs to be performed once. If svnpath is used, you must specify the corresponding paths for each file library.
For convenience, svnparentpath is used to specify the URL path of the parent layer of all file libraries. Add the above settings to the end of the httpd. conf file of Apache HTTP server.
Next, you can create a file library under D:/SVN.
2.4 create a file library
Suppose we want to put all the file libraries under the D:/SVN directory. Now we need to create a file library for testing. The name is repository and the command is:
Md d:/SVN
Svnadmin create d:/SVN/Repository
After the command is executed, check which directories and files are generated under the D:/SVN/Repository directory.
Warning
A file library cannot be created on any remote storage media, such as a network hard drive.
At this time, you have created a file library. You can first test it in the local browser. Enter http: // 127.0.0.1/SVN/Repository or http: // localhost/SVN/Repository, see if you can see the contents of the file library. If it is normal, it should be the same.
If the above test can pass, it should be done. If the IP address of the svn server installed in your LAN is 192.168.1.8, enter HTTP on another machine (client) in the LAN: // 192.168.1.8/SVN/Repository, you can see the same picture. If not, contact your network administrator.
If you want to test whether the entire working copy can be retrieved from the file library (this operation is not required), you can enter the target directory (assume d:/svn_temp) execute the following command to retrieve the entire working copy from the file Library:
SVN Co http: // localhost/SVN/Repository wholerepos
This command requires svn.exe to execute the check out action (CO). If it is correct, it will display "checked out Revision 0. ", at this time, all the file directories under the D:/SVN/repository file library have been taken out, and copied to the D:/svn_temp/wholerepos directory.
Troubleshooting
If the error message is:
SVN: PROPFIND request failed on '/SVN/Repository'
SVN: propfind of '/SVN/repository': 405 method not allowed (http: // localhost /)
Check httpd of Apache HTTP server. the <location> mark in the conf file indicates whether the location is the same as the URL style you specified. Note that the location must be exactly the same. In the above example, your httpd. the end of conf should contain the following text:
<Location/SVN>
Dav SVN
Svnpath: absolute path to the file library
</Location>
If the error message is:
SVN: PROPFIND request failed on '/SVN/Repository'
SVN:
Cocould not open the requested SVN filesystem
That means the reposiroty directory cannot be found in the experiment directory (D:/SVN) corresponding to/SVN.
Note: propfind is the HTTP Method Used for WebDAV to obtain attributes from resources.
So far, you can confirm that the file library has been created, and then you can introduce the project.
2.5 introduce a project
You don't need to rush to introduce your existing formal project to the file library. Suppose we have a test project, and the project directory is located at D:/svn_temp/projecta, there are the following sub-directories (you can also copy some files to these sub-Directories ):
Trunk
Branches
Tags
Enter the D:/svn_temp/projecta directory and execute the following command to introduce the test project to the file library.
D:/SVN/Repository/projecta.
SVN import. http: // localhost/SVN/Repository/projecta-M "Initial repository layout"
Prompt
This article uses the HTTP protocol to execute SVN commands, so that we can be sure that the subversion and Apache HTTP Server are not configured with a license, and others can access the file library through the Internet. Of course, you can also use other protocols, such as http://www.cnblogs.com/khler/admin/file://. if the file protocol is used, the command should be changed:
SVN import. http://www.cnblogs.com/khler/admin/file:///d:/svn/repository/projectA-M "Initial repository layout"
If the command is executed correctly, the following figure is displayed:
At this time, the project has introduced the file library (you will find that a file named 1 is added to the D:/SVN/Repository/DB/revs directory), that is, other users can start to access the project of this file library to retrieve the file and program code. You can refer to how to use the Client Command column tool svn.exe in the official manual of subversion to learn more about how to retrieve files, add files, and store files. If an error occurs during the exercise or the file library is messy, you can cut down the directory of the entire file library and go back to section 2.4 and repeat it.
The following will further discuss the arrangement of the file library and the project directory structure. If you want to try out how the client can access the Subversion file library, you can skip to section 2.6 or section 3rd first.
2.5.1 file library and project configuration
If we want to introduce multiple projects in the repository file library, for example, place the D:/svn_temp/projectb project under the Repository/projectb directory, then go to the project TB directory, use the following command to introduce projectb:
SVN import. http: // localhost/SVN/Repository/projectb-M "Initial repository layout"
After projectb is introduced, the directory structure of the repository file library will become as follows:
/SVN/Repository/
+ -- Projecta/
+ -- Projectb/
That is to say, the repository file library contains two projects.
If you want to create a file library for each project, the command for creating a file library in section 2.4 becomes:
Md d:/SVN
Svnadmin create d:/SVN/projecta
Svnadmin create d:/SVN/projectb
In this way, there are two file libraries named projecta and projectb respectively.
Prompt
If there are shared files between projects, we recommend that you put these related projects into the same file library. If there is no relationship between projects, you should put one file library into one project, this means that the project is a file library.
The first method has a strange "function". You should know that the check in action of a project also increases the revision number of files of other projects, if this is not what you want, select the second method, that is, a file library stores only one project.
2.5.2 project directory structure
The following describes the directory structure of projecta. The trunk, branches, and tags directories created under the root directory of the Project project have special meanings. Their functions are as follows:
• The trunk directory is used to store the program files and documents (also known as the main line, mainline) currently under development in the project );
• Branches is used to store the branches of the main line that are still developing;
• Tags is used to store the branches that are no longer changed, that is, the files in the branches will not be modified.
This is the directory structure arrangement method recommended by the subverion official manual. You can decide whether to use this configuration method by yourself. For details, refer to chapter 5 of the official manual, the sub-title is "choosing a repository layout ".
Prompt
We recommend that you do not use a Chinese name for the directory name. This makes it easier to use command columns and does not cause any problems.
2.6 Access Control
2.6.1 basic access control
Follow the steps above and you will find that you do not need to enter the account password when accessing the file library, because the identity authentication function is not enabled in our previous settings. However, we usually do not want everyone to have access to your file library at will, to avoid leakage of important information or data destruction. Therefore, it is necessary to know how to add authentication.
Sebversion provides multiple ways to verify user identity. First, we will introduce basic access control and perform the following steps:
1. Modify <location> of httpd. conf as follows:
<Location/SVN>
Dav SVN
Svnparentpath D:/SVN
Authname "Subversion repository"
Authzsvnaccessfile "D:/SVN/accessfile.txt"
Require valid-user
Satisfy any
# The following is basic authentication setting
Authtype basic
Authuserfile "D:/SVN/passwd.txt"
</Location>
Authzsvnaccessfile specifies the file library access policy file. require valid-use indicates that only authenticated users can access the file, satisfy any indicates that anonymous access is allowed (to be used with the * parameter mentioned later). authuserfile is used to indicate the location of the password file created using htpasswd.
If you want to use different access policy files and password files to control different file libraries, you can go to httpd. write multiple <location> </location> modules in conf and use svnpath to specify the absolute path of each file library (see 2.3.2 ).
2. Use Apache's htpasswd command to generate the user name and password:
Htpasswd-CM d:/SVN/passwd.txt username1
Htpasswd-m d:/SVN/passwd.txt username2
The htpasswd parameter-C is used to create a file. Therefore, the password can be changed only when the-M parameter is used for the first time.
3. Configure the file library access policy file (assuming projecta and projectb have been created under the repository file library), such:
[Repository:/]
Username1 = RW
[Repository:/projecta]
Username2 = r
[Repository:/projecta/trunk]
Username1 =
Username2 = RW
[Repository:/projectb]
* = R
[Repository:/projectb/trunk]
Username1 =
Do not omit the file library name before the colon in the section name. If it is omitted, it indicates that it is for all file libraries. This is dangerous. The "*" symbol represents all users, if it is null after the equals sign, the mod_authz_svn module will first find the directory that matches it, then the parent directory, and the parent directory of the parent directory. This will be followed by the recently found description. In addition, you can define a group of users and Configure permissions by group. For example:
[Groups]
Department_1 = username1, username2
Department_2 = username3, username4, username5
[Repository:/projecta]
@ Department_1 = r
@ Department_2 = RW
4. restart Apache (NOTE: For httpd. conf modification takes effect only after Apache is restarted.) Open the browser and enter the URL http: // 127.0.0.1/SVN/Repository. You should see the following verification screen:
5. if you want to allow users to remotely modify their subversion password, it is also very simple. Someone has already done the relevant work and can access the cgi-bin subdirectory of the supervisor <apache_root>, then modify the configuration file passwd. CGI. in INI, The auth_user_file path points to the full path of the actual authuserfile (for example, "d:/SVN/passwd.txt"). Then you can access HTTP: // localhost/cgi-bin/passwd. CGI changed the Subversion password.
2.6.2 sspi authentication Access Control (using Windows domain account verification)
This method is suitable for scenarios where development team members are on the Regional Network. follow these steps:
1. Get the sspi module, download URL (there is a version correspondence between APACHE and sspi, pay special attention to): http://www.gknw.net/development/apache/httpd-2.0/win32/modules/mod_auth_sspi-1.0.2-2.0.54.zip
2. Decompress mod_auth_sspi.so under the bin directory in mod_auth_sspi.zip to the <apache_root> \ modules directory.
3. Add the following line to httpd. conf of Apache:
Loadmodule sspi_auth_module modules/mod_auth_sspi.so
Note that the preceding line must be placed before the following line:
Loadmodule auth_module modules/mod_auth.so
4. Modify <location> of httpd. conf as follows:
<Location/SVN>
Dav SVN
Svnparentpath D:/SVN
Authname "Subversion repository"
Authzsvnaccessfile "D:/SVN/accessfile.txt"
Require valid-user
Satisfy any
# The following is sspi authentication setting
Authtype sspi
Sspiauth on
Sspiauthoritative on
Sspidomain <domaincontroller>
Sspiofferbasic on
</Location>
<Domaincontroller> is the computer name of your Windows Domain Controller (for example, win2kdc). Note that the brackets on both sides are not retained. <>. If your environment does not have a domain controller, you can maintain the original <domaincontroller>. In my environment, I found that even if I have a domain controller, I still can verify the user's identity normally without setting it here. In addition, authuserfile is no longer required to indicate the password file. Modify the access policy file of the file Library:
[Repository:/]
Domain \ username1 = RW
[Repository:/projecta]
Domain \ username2 = r
[Repository:/projecta/trunk]
Domain \ username1 =
Domain \ username2 = RW
[Repository:/projectb]
* = R
[Repository:/projectb/trunk]
Domain \ username1 =
5. Restart Apache, open the browser, and enter the URL http: // 127.0.0.1/SVN/Repository. The verification screen should also be displayed. However, if this screen is not displayed, the file library content is directly displayed. What is the problem?
Because we are now using Windows Account Verification, you have logged on to this machine, and what you want to access is the resources of this machine. In other words, your identity has been verified, therefore, you will not be asked to enter your account and password. This is a benefit of sspi Domain Verification.
So, if your colleague John's computer has joined the domain, but he usually logs in to the local computer rather than the domain, will he require the account and password to be entered when accessing the file library? The answer is that if John's account and password for logging on to his local machine are exactly the same as those for his domain user account and password, no password needs to be entered. On the contrary, if the user account and password used to log on to the local machine are different from the domain user account and password, you must enter the password for the first access.
On other machines, you can use a user account that does not exist in a domain to access the subverion file library. If it is correct, a window asking you to enter your account and password appears.
The above are some basic settings. If you want to further set up or add an SSL encryption mechanism, we recommend that you refer to Chapter 3 of [2.
Prompt
After authentication is enabled, you will find that when you use the command column tool svn.exe to access the file library, if you use http: // protocol, some sub-commands (subcommand) the "Authorization failed" error occurs during execution. You can add -- username and -- password to the svn command to provide the user name and password. For example:
SVN Co http: // myserver/SVN/-- username Michael -- password guesswhat
Or you can switch to http://www.cnblogs.com/khler/admin/file:/// protocols.
2.7 submit Control
2.7.1 restrict the submission of specific file types
When the client submits a change point, to restrict the submission of certain types of files, you can create a pre-commit.bat file under the hooks directory of the appropriate repository directory, and copy the following command to the pre-commit.bat.
@ Echo off
Set svn_bindir = "C: \ Program Files \ subversion \ bin"
Setlocal
Set repos = % 1
Set txn = % 2
Rem check that the file type is permitted or not
% Svn_bindir % \ svnlook changed "% repos %"-T "% txn %" | findstr "\. OBJ $ \. o $ \. bak $ \. SCC $ \. NCB \/recovery. "> NUL
If % errorlevel % equ 0 goto filetypeerror
Exit 0
: Filetypeerror
Echo submission failed. You cannot submit. OBJ,. O,. Bak,. SCC,. NCB, or files starting with "DUPLICATE".> & 2
Exit 1
The path after svn_bindir should be modified to your actual subversion installation path; repos represents the first parameter REPOS-PATH (the path to this repository) When SVN calls pre-commit ); txn represents the second parameter TXN-NAME (the name of the transaction about to be committed); findstr "\. OBJ $ \. o $ \. bak $ \. SCC $ \. NCB \/recovery. "indicates that. OBJ ,. O ,. bak ,. SCC ,. NCB is the end or line containing "/Duplicate. Of course, you can also use a similar method to allow users to only submit certain types of files.
2.7.2 force log-message input
When the client submits a change point, if you need to force the delivery of information in the message bar, you can use the svnlook log command implementation, in the corresponding location of the pre-commit.bat file to add the following two instructions:
Rem check that log-message contains at least 10 Characters
% Svn_bindir % \ svnlook log "% repos %"-T "% txn %" | findstr "......"> NUL
If % errorlevel % gtr 0 goto nomessage
: Nomessage
An error occurred while submitting the echo statement. Enter at least 10 characters in the message input box.> & 2
Exit 1
The number of characters that must be entered at least is determined by the number of. After findstr.
2.7.3 a log-message modification method
After the client submits a modification point, its log-message information cannot be modified. However, if a key error occurs in the log-message information, the following methods can be used to save the modification:
1. Create a TXT file on the server, such as newlog.txt, and then write the new log-message to it.
2. Open the command line and enter the directory where newlog.txt is located. Execute the following command:
Svnadmin setlog D:/SVN/repository-R n -- bypass-hooks newlog.txt
N indicates the revision number of the log-message to be modified. -- bypass-hooks indicates that the pre-revprop-change hook is not used.
It is not recommended to modify log-message.
3. Install the client tortoisesvn
Now you have a Subversion server that can operate. You can try to access the file library on another computer. If you are used to the command column tool, you only need to install the Subversion on the client computer. The command column tool (mainly svn.exe) is used to access the file library ). Here we will introduce a subversion client specifically designed for the Windows operating system: tortoisesvn (tsvn ).
3.1 install tortoisesvn
1. Go to http://tortoisesvn.tigris.org/to download the latest installer, such as a TortoiseSVN-1.4.0.7501-win32-svn-1.4.0.msi. After the installation is complete, you will be asked to reboot.
2. To http://tortoisesvn.tigris.org/download the Simplified Chinese Language Pack, please note that the Language Pack version should be the same as the tsvn version installed with, otherwise it is best not to install.
After the Language Pack is installed, use the resource manager to right-click the Windows desktop or any folder and choose tortoisesvn-> Settings, in the "Main" tab, change the language to "Chinese (simplified)" and click "OK.
3. if you access the Internet through the proxy server, switch to the "network" page in the tsvn setting window, and enter information about your proxy server, otherwise, you will not be able to access the file library on the Internet.
After the installation is complete, right-click any directory name to view the tsvn function options. This is also a convenient place for tsvn. It does not need to be integrated with development tools, it is integrated with the operating system, so that no matter what development tools you use, you can easily use tsvn to access the file library. If you want to use the beyond compare tool in tsvn to compare files, right-click any directory after installing beyond compare on the client, go to tortoise --> Settings --> external programs --> diff viewer/merge tool/uniied diff viewer and specify the bc2.exe path in external programs.
Next, you can use tsvn to practice accessing the previously created file library, try to introduce your existing project into the file library, and use tsvn on the client to perform operations such as pulling, storing, and updating.
Although tsvn is a client tool, it also provides functions such as creating a file library and introducing and extracting files. Therefore, it is quite convenient to install tsvn on the server.
Here are some considerations when the client submits the changes: