SVN Install Guide

stuqbx發表於2011-10-12
  1. Introduction

1.1 Installing Subversion

1.1.1 The Subversion Windows installation package can be downloaded from the Subversion server, at the following URL:

 http://subversion.apache.org/packages.html

I have downloaded the distribution packaged in a standard Windows installation program. For the Subversion version 1.6.3, grab the file named Setup-Subversion-1.6.3.msi .

The installation itself is completely straight-forward. You read [and accept] a license agreement, select the destination directory, press Next a couple of times, wait for the file copying to stop and press finish. What you get in the end, is the Subversion is installed in the directory you have specified.

The default directory is C:\Program Files\Subversion and I install in the directory D:\Program Files\Subversion, and here is a list of directories the installation creates:

D:\Program Files\Subversion\bin Contains all the binaries like svn.exe, svnadmin.exe and svnlook.exe. And Contains the Apache 2.2 plug-in modules mod_authz_svn.so and mod_dav_svn.so . D:\Program Files\Subversion\iconv D:\Program Files\Subversion\share D:\Program Files\Subversion\licences

The D:\Program Files\Subversion\bin is added to the path.

And that's about all there is to the installation.

At this point it is probably recommendable to restart the system, before moving on to configuration.

1.2 Installing Apache 2.2

1.2.1. The Apache 2.2 server for Windows installation package can be downloaded from the Apache.org server, at the following URL:

 http://httpd.apache.org/download.cgi

I have downloaded the distribution packaged in a standard Windows installation program - the httpd-2.2.17-win32-x86-openssl-0.9.8o.msi .

The installation itself is completely straight-forward. You read [and accept] a license agreement, select the Apache binding (I picked the 2.2.x), enter your domain name, server name, the administrator's e-mail address, and the port the server will be listening on. The default values are already selected for you. For dedicated a subversion server, I suggest you leave it running on port 80. You can always change it later.

Then you can select typical, or custom install. Selecting typical install lets you choose the destination directory, and after that it starts copying files. When it finishes, you're done.

  1. Configuration

2.1 Configuring Subversion

The Subversion stores the content into so called repositories. You need at least one repository to store all your data into, or may have multiple repositories, one for each project. This HOWTO will assume multiple repositories are used. We will call these projects project1 and project2.

So, let's create a directory for all our projects, and then a subdirectory for each of the projects, e.g.:

D:\Repositories\project1D:\Repositories\project2These are just directories to hold our repositories, now we must create the repositories themselves, using the svnadmin utility:

svnadmin create D:\Repositories\project1
svnadmin create D:\Repositories\project2

2.2 Configuring Apache 2.2 server

As the Apache server will only be a front end for the Subversion system, I suggest that all the Subversion specific files are stored in a separate directory, which is at hand, and not hidden away in some Apache directory. In the best spirit of *nix systems, let us name that directory etc.

D:\etc

But, before we start with the Subversion specific configuration, let us make the necessary steps and configuration changes, to link the Apache server with Subversion.

Step 1 (add some svn refrence module to apache)

Copy the files mod_authz_svn.so and mod_dav_svn.so from D:\Program Files\Subversion\bin into D:\Program Files\Apache Software foundation\Apache2.2\modules .

Step 2 (modify configure file)

Modify the D:\Program Files\Apache Software foundation\Apache2.2\conf\httpd.conf file:

Add the modules to the Apache server:

  1. Delete "#
                        #LoadModule dav_fs_module modules/mod_dav_fs.so
                        #LoadModule dav_module modules/mod_dav.so






which in D:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd

  1. Add these codes at the end of "LoadModule? ... "
                        LoadModule dav_svn_module modules/mod_dav_svn.so 
                        LoadModule authz_svn_module modules/mod_authz_svn.so

At the end of the file, include a Subversion configuration file. We will create this file in one of the next steps.

Include D:/etc/subversion.conf (the file subversion.conf define next)

Step 3

Our decision was that anonymous access to repositories will not be allowed. Also, we would like that only the developers working on a specific project, can modify the contents of that project's repository. All other developer will have read only permissions to all projects. After all, we want our developers to share their code, don't we.

So first, we create a password file for authentication. All the developers that will use our Subversion server must chose a user name and a password. Unfortunately, the simplest way to do this is locally, so you must ask all the developers to come to the system and enter chose a password.

In the best tradition of Subversion book, let us name our developers Harry and Sally. Since we have two projects, we'll have a somewhat bigger development department, adding Ross and Rachel to our list of employees.

-------------------------------------------------------------------------------------------------

	cd D:\Program Files\Apache Software Foundation\Apache2.2\bin 
					
	D:\Program Files\Apache Software Foundation\Apache2.2\bin>htpasswd -cm D:\etc\svn-auth-file harry
	New password: ***** 
	Re-type new password: *****
	Adding password for user harry

	D:\Program Files\Apache Software Foundation\Apache2.2\bin>htpasswd -m D:\etc\svn-auth-file sally
	New password: *******
	Re-type new password: *******
	Adding password for user sally

	D:\Program Files\Apache Software Foundation\Apache2.2\bin>htpasswd -m D:\etc\svn-auth-file ross
	New password: ***** 
	Re-type new password: *****
	Adding password for user ross

	D:\Program Files\Apache Software Foundation\Apache2.2\bin>htpasswd -m D:\etc\svn-auth-file rachel
	New password: ***** 
	Re-type new password: *****
	Adding password for user rachel

--------------------------------------------------------------------------------------------------

When using the command for the first time, add the -c option. This creates the file named D:\etc\svn-auth-file . The -m option instructs the htpasswd utility to use MD5 algorithm to encrypt the passwords.

Step 4

Now that we can authenticate our users, we must configure the access rights to our repositories. To do this, we create another file in our etc directory.

D:\etc\svn-acl

--------------------------------------------------------------------------------------------------

	#
	# specify groups here
	#
	[groups]
	team1 = ross, rachel

	#
	# team1 group has a read/write access to project1 repository
	# all subdirectories
	# all others have read access only 
	#
	[project1:/]
	@team1 = rw
	* = r

	#
	# project2 repository, only harry and sally have read-write access to project2
	#
	[project2:/]
	harry = rw
	sally = rw
	* = r

	#
	# ross is helping with the time zone part of the project2
	#
	[project2:/timezone]
	harry = rw
	sally = rw
	ross = rw
	* = r

--------------------------------------------------------------------------------------------------

The groups section can be used to define groups of users. For repository project1, only users from the group team1 have read/write access. All other users have read only access.

Step 5

In the end it is time to link the Apache server with the Subversion. This is done using the D:\etc\subversion.conf file:

---------------------------------------------------------

				<Location /project1>
				  DAV svn
				  SVNPath D:/Repositories/project1

				  AuthType Basic
				  AuthName "Subversion Project1 repository"
				  AuthUserFile D:/etc/svn-auth-file

				  Require valid-user

				  AuthzSVNAccessFile D:/etc/svn-acl
				</Location>

				<Location /project2>
				  DAV svn
				  SVNPath D:/Repositories/project2

				  AuthType Basic
				  AuthName "Subversion Project2 repository"
				  AuthUserFile D:/etc/svn-auth-file

				  Require valid-user

				  AuthzSVNAccessFile D:/etc/svn-acl
				</Location>
				
-----------------------------------------------------------

The developers can access the D:\Repositories\project1 repository at the  http://subversion/project1(http://localhost/project1/) URL. The access is only available to a valid user, and a basic HTTP authentication is used. The Apache server can read the valid user names and passwords from the D:\etc\svn-auth-file file. The D:\etc\svn-acl file defines the access rights to the repository.

  1. Restart the Apache server for the configuration changes to take effect

 

 

Reproduced, please indicate the source!

相關文章