Dave Perrett

Svn Server W/ Apache

database, linux, programming, subversion, version control, web

  1. Make sure you have a newish version of libtool
1
2
3
4
5
6
$ wget http://ftp.gnu.org/gnu/libtool/libtool-1.5.22.tar.gz
$ tar xvzf libtool-1.5.22.tar.gz
$ cd libtool-1.5.22
$ ./configure
$ make
$ make install
  1. Make sure you have a newish version of autoconf
1
2
3
4
5
6
$ wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz
$ tar xvzf autoconf-2.61.tar.gz
$ cd autoconf-2.61
$ ./configure
$ make
$ make install
  1. Install BerkeleyDB
1
2
3
4
5
6
7
$ wget http://downloads.sleepycat.com/db-4.4.20.tar.gz
$ tar xvzf db-4.4.20.tar.gz
$ cd db-4.4.20/build_unix/
$ ../dist/configure
$ make
$ sudo make install
$ sudo /sbin/ldconfig
  1. Install Python
1
2
3
4
5
6
$ wget http://www.python.org/ftp/python/2.5/Python-2.5.tgz
$ tar xvzf Python-2.5.tgz
$ cd Python-2.5
$ ./configure
$ make
$ sudo make install

Make sure we are using the right python executable

1
2
3
$ sudo rm -Rf /usr/bin/python
$ sudo ln -s /usr/local/bin/python /usr/bin/python
$ sudo /sbin/ldconfig
  1. Install Swig
1
2
3
4
5
6
7
$ wget http://jaist.dl.sourceforge.net/sourceforge/swig/swig-1.3.28.tar.gz
$ tar xvzf swig-1.3.28.tar.gz
$ cd swig-1.3.28
$ ./configure --with-python=/usr/local/bin/python
$ make
$ sudo make install
$ /sbin/ldconfig
  1. Install Apache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$ wget http://www.apache.org/dist/httpd/httpd-2.2.4.tar.gz
$ tar xvzf httpd-2.2.4.tar.gz
$ cd httpd-2.2.4
$ cd srclib/
$ rm -Rf apr/*
$ svn co http://svn.apache.org/repos/asf/apr/apr/branches/1.2.x apr
$ rm -Rf apr-util/*
$ svn co http://svn.apache.org/repos/asf/apr/apr-util/branches/1.2.x apr-util
$ cd ../
$ ./buildconf
$ sudo echo '/usr/local/BerkeleyDB.4.4/lib/' >> /etc/ld.so.conf
$ sudo /sbin/ldconfig
$ ./configure \
         --enable-dav=shared \
         --enable-dav_fs=shared \
         --enable-expires=shared \
         --enable-deflate=shared \
         --enable-rewrite=shared \
         --disable-userdir \
         --enable-maintainer-mode \
         --with-dbm=db4 \
         --with-berkeley-db \
         --prefix=/usr/local/apache-2.2.4
$ make
$ sudo make install
  1. Install Subversion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ wget http://subversion.tigris.org/downloads/subversion-1.4.0.tar.gz
$ tar xvzf subversion-1.4.0.tar.gz
$ cd subversion-1.4.0
$ mkdir apr
$ svn co http://svn.apache.org/repos/asf/apr/apr/branches/1.2.x apr/
$ mkdir apr-util
$ svn co http://svn.apache.org/repos/asf/apr/apr-util/branches/1.2.x apr-util/
$ ./autogen.sh
$ make clean
$ ./configure \
         --with-apxs=/usr/local/apache-2.2.4/bin/apxs \\
         --with-apr=/usr/local/apache-2.2.4/bin/apr-1-config \
         --with-apr-util=/usr/local/apache-2.2.4/bin/apu-1-config \
         --with-berkeley-db=/usr/local/BerkeleyDB.4.4 \
         --enable-swig-bindings=python \
         --with-zlib \
         --with-swig=/usr/local

Before compiling, make sure the makefile python stuff is pointing to the right place

1
2
3
$ sed -ri "s|PYTHON = /usr/bin/python2|PYTHON = /usr/local/bin/python|" Makefile
$ sed -ri "s|/usr/include/python2.2|/usr/local/include/python2.5|" Makefile
$ sed -ri "s|SVN_APR_LIBS =  /usr/local/apache-2.2.4/lib/libapr-1.la -luuid -lrt -lcrypt  -lpthread -ldl|SVN_APR_LIBS =  /usr/local/apache-2.2.4/lib/libapr-1.la -luuid -lrt -lcrypt  -lpthread -ldl -L/usr/kerberos/lib -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lexpat|" Makefile

The extra SVN_APR_LIBS arguments (-L/usr/kerberos/lib -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lexpat) were obtained using the output of :

1
$ /usr/local/bin/neon-config --libs

The python and swig-py stuff isn’t really necessary unless you want to run Trac , but it doesn’t hurt to include it now just in case.

To build :

1
2
3
4
5
6
7
8
9
$ make
$ sudo cp ./subversion/mod_dav_svn/mod_dav_svn.la /usr/local/apache-2.2.4/modules/
$ sudo cp ./subversion/mod_dav_svn/.libs/mod_dav_svn.so /usr/local/apache-2.2.4/modules/
$ sudo cp ./subversion/mod_authz_svn/mod_authz_svn.la /usr/local/apache-2.2.4/modules/
$ sudo cp ./subversion/mod_authz_svn/.libs/mod_authz_svn.so /usr/local/apache-2.2.4/modules/
$ sudo make install
$ make swig-py
$ sudo make install-swig-py
$ sudo /sbin/ldconfig
  1. Make user & group
1
2
3
$ sudo /usr/sbin/groupadd -g 56 svn
$ sudo /usr/sbin/useradd -d /home/svn/ -ppassword -g svn -u 56 svn
$ sudo install -d -m0755 -o svn -g svn /home/svn/repositories
  1. Make a repository
1
2
3
4
$ sudo svnadmin create --fs-type fsfs /home/svn/repositories/my_project
$ sudo chown -R svn:svn /home/svn/repositories/my_project
$ sudo chmod -R g+w /home/svn/repositories/my_project
$ sudo chmod g+s /home/svn/repositories/my_project/db
  1. Configure Apache - add something like the following to httpd.conf:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
NameVirtualHost xxx.xxx.xxx.xxx:80

<virtualHost xxx.xxx.xxx.xxx:80>
  DocumentRoot /usr/local/apache-2.2.4/htdocs/
  ServerName svn.domain.name.here

  <directory "/usr/local/apache-2.2.4/htdocs/">
     Options Indexes FollowSymLinks
     AllowOverride All
     Order allow,deny
     Allow from all
  </directory>

  <location />
    DAV svn
    SVNParentPath /home/svn/repositories
    SVNListParentPath on
    SVNPathAuthz off
    AuthType Basic
    AuthName "svn.domain.name.here"
    AuthUserFile /usr/local/apache-2.2.4/passwd/passwords
    Require valid-user
  </location>

</virtualHost>

Swap the xxx.xxx.xxx.xxx with your server’s IP address, and the svn.domain.name.here with your domain. Also make sure that httpd.conf is setup to run apache as the ‘svn’ user.

  1. Create a password file
1
2
$ mkdir /usr/local/apache-2.2.4/passwd
$ sudo ./bin/htpasswd -c /usr/local/apache-2.2.4/passwd/passwords new_user_name

Where new_user_name is the name of the user you want to create.