Setting up a SVN 1.4 server using Apache 2.2 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 prev apache2 and subversion 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.4As 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*
$wget http://subversion.tigris.org/downloads/subversion-1.4.0.tar.gz
$tar xvfz subversion-1.4.0.tar.gz
$cd subversion-1.4.0/
$sh autogen.sh
$./configure --prefix=/usr/local --with-apxs=/usr/local/apache2/bin/apxs --with-httpd
In case you find a error for missing apr or apr tool give the following configure command
$./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$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 svnsync 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/ajopaul/subversion/repos --revprop -r 0 http://xxx.xxx.xxx.xxx/svn
$time sudo svnsync sync file:///home/ajopaul/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 $2 $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
-Ajo Paul
Source:
Apache 2.2Svn 1.4