Setting Up A Subversion Repository Using Apache, With Auto Updatable Working Copy

Want to support HowtoForge? Become a subscriber!
 
Submitted by fahdaziz (Contact Author) (Forums) on Mon, 2007-06-18 16:52. :: Apache

Setting Up A Subversion Repository Using Apache, With Auto Updatable Working Copy

Overview:

What is Subversion?

Subversion is a free/open-source version control system. That is, Subversion manages files and directories over time. A tree of files is placed into a central repository. The repository is much like an ordinary file server, except that it remembers every change ever made to your files and directories. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine”.

Subversion can access its repository across networks, which allows it to be used by people on different computers. At some level, the ability for various people to modify and manage the same set of data from their respective locations fosters collaboration. Progress can occur more quickly without a single conduit through which all modifications must occur. And because the work is versioned, you need not fear that quality is the trade-off for losing that conduit—if some incorrect change is made to the data, just undo that change.

Some version control systems are also software configuration management (SCM) systems. These systems are specifically tailored to manage trees of source code, and have many features that are specific to software development—such as natively understanding programming languages, or supplying tools for building software. Subversion, however, is not one of these systems. It is a general system that can be used to manage any collection of files. For you, those files might be source code—for others, anything from grocery shopping lists to digital video mixdowns and beyond.

Almost every Linux distribution comes with a standard subversion installed.

The repository is of two formats bdb (berkeley db database) and fsfs (fsfs database).

In our case we are using the FSFS database and the repository is created on /usr/local/subversion/repository

SVN has few methods to serve its users. Below are some examples:

1, SVN+SSH

2, SVN+Apache

3, SVNServe

In this case we are using the Apache method.

Apache should be running as an normal user, not nobody.

I won't guide people how to install apache in this how to.

Below is a step by step instruction on how to compile subversion from the source code, and how to setup a repository using apache webserver.

 

Documentation Contents:

1, Compiling subversion and its dependencies from source code

2, Creating a user for apache and modifying httpd.conf

3, Creating a repository

4, Setting up httpd.conf to serve the created repository

5, Setting up authentication

6, Adding SVN users

7, Setting up the initial repository layout

8, Setting up a working copy

9, Setting up the hook scripts

 

Compiling subversion and its dependencies from source code:

First of all, we need get the source code for subversion and its dependencies from http://subversion.tigris.org/

Some of the dependencies we need are,

APACHE (Webserver) (Source code isn't included in the subversion dependencies.)

APR

APR-UTIL

NEON

After setting up the apache webserver, we need to compile APR and APR-UTIL.

Do that by extracting the tarballs after downloading it from http://subversion.tigris.org/.

Extract both the subversion source code and the subversion dependencies source code.

tar -jxvf subversion-x.x.x.tar.bz2

tar -jxvf subversion-deps-x.x.x.tar.bz2

cd subversion-x.x.x

Now we'll compile the APR first.

cd apr

./configure --prefix=/usr/local/apr

make

make install

cd ..

Next we'll compile APR-UTIL.

cd apr-util

./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr/

make

make install

cd ..

After we're done with APR and APR-UTIL, we'll need to compile NEON.

cd neon

./configure --prefix=/usr/local/neon

make

make install

cd ..

Finally we need to compile subversion with the support for all the we just installed.

./configure --prefix=/usr/local/subversion --with-apxs={Location where you installed apache}/bin/apxs --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-neon=/usr/local/neon/ --with-ssl

make

make install

 

Creating a user for apache and modifying httpd.conf:

groupadd apache

useradd -g apache -d /usr/local/apache2

After installing apache we need to set ownership of all the files in /usr/local/apache2 to user apache.

chown -Rv apache.apache /usr/local/apache2

Finally we need to set which user the Apache server will be running as.

Edit the default configuration file, or whatever configuration file apache uses to run as.

I am going to assume the configuration file is /usr/local/apache2/conf/httpd.conf.

vi /usr/local/apache2/conf/httpd.conf

Locate the line where it states something like.

User nobody
Group #-1

Make it look like this.

User apache
Group apache

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by bsdxlr8r (registered user) on Fri, 2008-08-15 01:23.

./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr/

should be changed to

./configure --prefix=/usr/local/apr-utils --with-apr=/usr/local/apr/

Submitted by Prasad .Naik (INDIA) (not registered) on Thu, 2008-11-27 08:04.

/configure --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr/

should be changed to

./configure --prefix=/usr/local/apr-utils/bin  --with-apr=/usr/local/apr/

Submitted by Anonymous (not registered) on Thu, 2010-10-21 19:08.
This is the biggest load of crap ever. How come in order to get a subversion client I need a damn apache server? Has everyone on the svn team gone completely mad? Also, I love that if it doesn't find APR, the damn configure script tells you how to get it with SVN. That is the biggest WTF of my whole life with computers.
Submitted by rohni (not registered) on Wed, 2011-06-22 11:13.

If you have actually read the svn guide you would know that they advise using apache only if there is good reason.

Subversion comes with svnserve.  Please refer to: http://svnbook.red-bean.com/en/1.5/svn.serverconfig.choosing.html

 However for those of us that have good reason to use apache, and would like a sandboxed build for development and deployment this is a great start point.

 Thanks for writing this, I (and I am sure others) really appreciate it, as there is very little about the specifics in the subversion docs.

 Couple of things I have noticed:

The subversion tarball no longer includes the apr and apr-util source, if they ever did, you can find them here: 

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

Hope this helps.

 P.S. @Anonymous: The next time you decide, in your wisdom, to leave such helpful comments, could you, please, try and have a slight clue, and possibly take 30 seconds to glance and the excellent subversion documentation.

 Thank-you.