If everything worked out, you should now have a working, checked out copy of your freshly created SVN repo.

If everything worked out, you should now have a working, checked out copy of your freshly created SVN repo.

Revision as of 10:46, 24 April 2013

zh-CN:Subversion Setup"Apache Subversion is a full-featured version control system originally designed to be a better CVS. Subversion has since expanded beyond its original goal of replacing CVS, but its basic model, design, and interface remain heavily influenced by that goal."

This article deals with setting up an svn-server on your machine. There are two popular svn-servers, the built in svnserve and the more advanced option, Apache with svn plugins.

Apache Subversion Setup

Goals

The goal of this how to is to setup Subversion, with Apache. Why use Apache for Subversion? Well, quite simply, it provides features that the standalone svnserve does not have...

You get the ability to use https protocol. This is more secure than the md5 authentication used by svnserve.

You get fine-grained access controls. You can use Apache auth to limit permissions by directory. This means you can grant read access to everything, but commit access only to trunk for instance, while have another group with commit access to tags or branches.

You get a free repository viewer. While not very exciting, it does work.

The Subversion team is working on seamless webdav integration. At some point you should be able to use any webdav interface to update files in the repository.

Apache Installation

This howto does not cover installation and initial setup of the Apache web server. This is covered here.

To make sure the SSL settings get loaded, uncomment the SSL configuration line in /etc/httpd/conf/httpd.conf so it looks like this:

Include /etc/httpd/conf/extra/httpd-ssl.conf

Create /home/svn/.svn-policy-file

[/]
* = r
[REPO_NAME:/]
USER_NAME = rw

The * in the / section is matched to anonymous users. Any access above and beyond read only will be prompted for a user/pass by apache AuthType Basic. The REPO_NAME:/ section inherits permissions from those above, so anon users have read only permission to it. The last bit grants read/write permission of the REPO_NAME repository to the user USER_NAME.

Create /home/svn/.svn-auth-file

This is either an htpasswd, or htdigest file. I used htpasswd. Again, because of SSL, I do not worry as much about password sniffing. htdigest would provide even more security vs sniffing, but at this point, I do not have a need for it. Run the following command

# htpasswd -cs /home/svn/.svn-auth-file USER_NAME

The above creates the file (-c) and uses sha1 for storing the password (-s). The user USER_NAME is created.
To add additional users, leave off the (-c) flag.

# htpasswd -s /home/svn/.svn-auth-file OTHER_USER_NAME

Create a Repository

# svnadmin create /home/svn/repositories/REPO_NAME

Set Permissions

The Apache user needs permissions over the new repository.

# chown -R http:http /home/svn/repositories/REPO_NAME

Create a Project

Directory structure for project

Create a temporary directory with the branchestagstrunk directory structure on your development machine.

$ mkdir -p ~/svn-import/{branches,tags,trunk}

Populate Directory

Copy or move your project source files into the created trunk directory.

Start the server daemon

The -r /path/to/repos option set the root of repository tree. If you have multiple repositories use -r /path-to/reposparent. Then access independent repositories by passing in repository name in the URL: svn://host/repo1. make sure that the user has read/write access to the repository files)