Setting up a SVN 1.4 server using Apache 2.2 on Ubuntu 15

To setup svn 1.4 , we need to compile both apache 2.2 and svn 1.4 from source.
This how to has been tested under Ubuntu Dapper and Edgy.

sudo apt-get install build-essential libneon25-dev autoconf libtool -y --force-yes

Before starting make sure you have removed previous apache2 and subversion installation from your system.
To do this:
sudo apt-get --purge remove apache2 subversion
sudo mv /etc/init.d/apache2 $HOME/apache2_bak

cd $HOME
mkdir softwares
cd softwares

wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar xvfz zlib-1.2.3.tar.gz
cd zlib-1.2.3/
./configure --prefix=/usr/local
make
sudo make install

cd ..
wget http://apache.forbigweb.com/httpd/httpd-2.2.3.tar.gz
tar xvfz httpd-2.2.3.tar.gz
cd httpd-2.2.3/
./buildconf

./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate --enable-proxy --enable-proxy-balancer --enable-proxy-http --enable-dav --enable-so --enable-maintainer-mode

make
sudo make install

sudo /usr/local/apache2/bin/apachectl start
Now test your apache2! goto browser and type http://localhost, you should see it works!!

sudo /usr/local/apache2/bin/apachectl stop


sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apachectl
sudo chmod +x /etc/init.d/apachectl

We just need to add a few lines to the file for it to work nicely:

sudo vi /etc/init.d/apachectl

Add the followinig, so the top of the file looks like:

#!/bin/sh
#
# chkconfig: - 85 15
# description: Apache is a web server.

Save the file.

sudo /usr/sbin/update-rc.d apachectl defaults

Securing Apache

It?s also a good idea to create a dedicate Apache system user account. It?ll make your install much more secure.

sudo adduser --system apache

Now we just need to make sure that Apache runs under this user. We do that by editting the configuration file:

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

You need to find the lines that say:

User daemon
Group daemon

And change them so they look like:

User apache
Group nogroup

sudo /usr/local/apache2/bin/apachectl start

Installing Subversion 1.4

As we have built Apache from source, we’ll need to do the same for Subversion in order to get the Apache 2 modules mod_dav_svn and mod_authz_svn.

# rm -f /usr/local/lib/libsvn*
# rm -f /usr/local/lib/libapr*
# rm -f /usr/local/lib/libexpat*
# rm -f /usr/local/lib/libneon*

#Get the latest svn tar ball
wget http://subversion.tigris.org/downloads/subversion-1.4.2.tar.gz
tar xvfz subversion-1.4.2.tar.gz
cd subversion-1.4.2/

sh autogen.sh

./configure --prefix=/usr/local --with-apxs=/usr/local/apache2/bin/apxs --with-httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr

make
sudo make install

This will also add the relevant LoadModule directives into your Apache 2 configuration for you.
Creating your repository

Now, create your Subversion repository:

svnadmin create /home/yourusername/subversion/repos

We have to make that repository owned by Apache so that it can be accessed via the web:

sudo chown -R apache /home/yourusername/subversion/repos

Authentication File

Now create a user/password file for authentication:

/usr/local/apache2/bin/htpasswd -cm /home/yourusername/subversion/dav_svn.passwd yourusername

When prompted, enter your password.
Configuring Apache

Edit your /usr/local/apache2/conf/httpd.conf file with the following placed at the end:


<Location /svn>
DAV svn
SVNPath /home/yourusername/subversion/repos
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /home/yourusername/subversion/dav_svn.passwd
Require valid-user
</Location>

If you want access control based on different users, add the following line after the Require valid-user line:

AuthzSVNAccessFile /home/yourusername/subversion/svn_access_control

To setup a local mirror using svnsync

To have a mirror setup first ensure that the local repo you are going to use as the mirror should have the same uuid as that of the master.

To get uuid of a repo, go to its working copy and type
svn info

now make the mirror svn’s uuid same as masters uuid, you can get the uuid by typing
svn info URL/PATH

cat – <<EOF | sudo svnadmin load –force-uuid dest
SVN-fs-dump-format-version: 2

UUID: d48dd586-eb1d-0410-b581-e6e13afcedeb
EOF

cd /home/ajopaul/subversion/repos/hooks/
vi pre-revprop-change
sudo vi pre-revprop-change

Add the following lines
#!/bin/sh
USER="3"
if [ "USER" = "svnsync" ]; then exit 0; fi
echo "Only svnsync user can change revprops" >&2
exit 1

sudo chmod +x pre-revprop-change

sudo svnsync init --username your_master_svn_username file:///home/ajopaul/subversion/repos http://xxx.xxx.xxx.xxx/svn

sudo svn proplist --revprop -r 0 http://xxx.xxx.xxx.xxx/svn

sudo svn propget file:///home/yourusername/subversion/repos --revprop -r 0 http://xxx.xxx.xxx.xxx/svn

time sudo svnsync sync file:///home/yourusername/subversion/repos

Remember! local mirrors is/should be read only

To ensure no commits happen on the local mirror add the following lines to hooks/pre-commit script

#!/bin/sh
SVNLOOK=/usr/local/bin/svnlook
USER=`SVNLOOK author -t $3 $1`
if [ "$USER" = "svnsync" ]; then
exit 0;
fi
echo "Sorry no commit allowed on mirror! use 'svn switch' to point to master repo and then point back to local mirror after the commit" >&2
exit 1

If by any chance your svnsync locks ur mirror repo or if you recieve a message such as:
Failed to get lock on destination repos, currently held by ….
Type this
svn propdel svn:sync-lock --revprop -r 0 file:///home/ajopaul/subversion/repos/

References:
Source
svnsync.txt

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

15 thoughts on “Setting up a SVN 1.4 server using Apache 2.2 on Ubuntu

  1. Reply Jaime Ganley Sep 21,2010 12:43 am

    Was Just was doing some research and suprised by the information you wrote. Read exactly what I wanted too. Write more!

  2. Reply Osvaldo Oct 10,2007 9:26 pm

    I have a problem during the “make” of subversion source…
    ….. /usr/bin/ld: cannot find -lexpat

    I have tested expat from source, apr&apr-util from source… always the same problem 🙁

    Any idea ?

    Thank
    Osvaldo
    P.S. FreeBsd 6.2 apache 2.2.6 subversion 1.4.5

  3. Reply Andrew Powell Sep 6,2007 1:25 pm

    I too have problems using svnsync with apache https.
    It works fine with standard http, but https produce an errorlevel of 1 in the .bat file that I am running.

    I have it hooked into the post-commit.bat hook. What am I missing?
    Spend hours on this

    Below is the .bat code

    rem —- Start —–
    @echo off

    svnsync synchronize https://165.56.1.21:443/sslrepo2 –username test –password pwd >> “errors.txt”

    IF %ERRORLEVEL%==0 GOTO end
    echo “Error – %ERRORLEVEL%” >> “errors.txt”

    :end
    rem —— Finish ——-

  4. Reply Jose Prado Apr 3,2007 10:50 am

    Nice tutorial, it worked for me, but what about SSL on apache with this configuration?

    It doesnt work SSL for me with this.

    I get the -12663 error

  5. Reply Ajo Paul Feb 7,2007 6:13 am

    @Dustin,
    Well I guess you might be referring to GUI packages for svn like kdesvn, rapidsvn , I did initially run into trouble as I had installed them when i had svn 1.3.2 from repos. Well after that dint really have a need for them, hence havent tried. I’l let you know if it works with 1.4. Or is it something else you are referring to??

    -Ajo

  6. Reply Dustin Feb 6,2007 11:12 pm

    Nice howto. I previously compiled SVN 1.4 for my system, but theres still random packages that I want to install using apt that have svn as a dependency. Of course, I already have SVN, just not the package.. any ideas on how to create a dummy package or something to that effect?

  7. Reply ajopaul Jan 24,2007 6:08 pm

    @Jeff

    Thanks for bringing that up, Well that was a typo i guess the httpd.conf at the end should look like this

    <Location /svn>
    DAV svn
    SVNPath /home/username/subversion/repos

    AuthType Basic
    AuthName “Subversion Repository”
    AuthUserFile /home/username/subversion/dav_svn.passwd
    Require valid-user
    </Location>

  8. Reply ajopaul Jan 24,2007 6:04 pm

    @Joe

    Haven’t tried it windows, yet its definitely possible. A how to on setup of svn1.3 should be work for 1.4 also. The main purpose of using 1.4+ is that it allows us to have a mirror repository. May be this should help

    http://blogs.vertigosoftware.com/teamsystem/archive/2006/01/16/Setting_up_a_Subversion_Server_under_Windows.aspx

  9. Reply Joe Jan 24,2007 1:21 am

    I was wondering how do I go about installing SVN 1.4 on Apache 2.2 on Windows? Any site or information you can recommend? Thanks…

  10. Reply Jeff Sidlosky Jan 20,2007 11:35 pm

    I tried surrounding the change with [directory /] (but a lesser/greater sign) and , that seems to work, but I dont know if thats what I should be doing.

  11. Reply Jeff Sidlosky Jan 20,2007 11:34 pm

    I tried surrounding the change with > and , that seems to work, but I dont know if thats what I should be doing.

  12. Reply Jeff Sidlosky Jan 20,2007 11:34 pm

    When trying to start apache after configuring it via your instructions:
    Syntax error on line 465 of /usr/local/apache2/conf/httpd.conf:
    DAV not allowed here.

    I tried surrounding the change with and , that seems to work, but I dont know if thats what I should be doing.

  13. Reply Ajo Paul Jan 20,2007 6:27 pm

    Thanks for the udpate, have updated the howto to include the apr-util while compiling svn.

  14. Reply DonRolando Jan 11,2007 7:02 pm

    Hello
    Cool How-To
    But I have a little problem during httpd make install
    libexpat.la was not in the directory, so I have read the error message.
    I go into the concerned directory and type :
    ./configure
    make
    after this compilation, the libexpat.la file is in the directory !
    I rerun the httpd “sudo make install”.
    And now, all right for Apache2
    Thanks

Leave a Reply to ajopaul Cancel Reply

  

  

  

*