Latest and greatest Subversion on Debian Lenny
Debian has its own package for Subversion, but most of the time you want to use the latest Subversion package that's out there. This explains how to build and use that over Apache and HTTPS.
Installation
This particular install does not use the Berkeley DB method of code repository storage, but rather the flat file system storage method. Both have their advantages, but the file is believed to be faster. Read more here.
First setup Apache and get all the Subversion dependencies.
apt-get build-dep subversion
cd /usr/src
wget http://subversion.tigris.org/downloads/subversion-1.6.13.tar.gz
tar zxvf subversion-1.6.13.tar.gz
cd subversion-1.6.13
./configure --prefix=/usr/local
Then we get this warning, but FSFS is fine to use instead of Berkeley.
configure: WARNING: we have configured without BDB filesystem support You don't seem to have Berkeley DB version 4.0.14 or newer installed and linked to APR-UTIL. We have created Makefiles which will build without the Berkeley DB back-end; your repositories will use FSFS as the default back-end. You can find the latest version of Berkeley DB here: http://www.oracle.com/technology/software/products/berkeley-db/index.html
Continue with the build:
make install
After install, this error comes up, but it can be ignored and the next few steps will fix.
apxs:Error: Activation failed for custom /etc/apache2/httpd.conf file.. apxs:Error: At least one `LoadModule' directive already has to exist.. make: *** [install-mods-shared] Error 1
Create the file /etc/apache2/mods-available/dav_svn.load with the following:
LoadModule dav_svn_module /usr/lib/apache2/modules/mod_dav_svn.so
LoadModule authz_svn_module /usr/lib/apache2/modules/mod_authz_svn.so
Copy over the modules from source and install them in the Apache directories; also enable SSL since we want to push this over a secure channel:
cp /usr/src/subversion-1.6.11/subversion/mod_authz_svn/.libs/mod_authz_svn.so /usr/lib/apache2/modules/
a2enmod dav_svn
a2enmod ssl
Configuration
Create the file /etc/apache2/sites-available/svn so that Apache knows about the SVN repository:
<VirtualHost svn.mysite.com:443>
DocumentRoot /var/svn
# SSL Definitions
SSLEngine on
SSLCertificateFile /etc/ssl/private/myserver_svn.crt
SSLCertificateKeyFile /etc/ssl/private/myserver_svn.key
# Subversion
<Location /svn>
DAV svn
SVNListParentPath on
SVNParentPath /var/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/svn/dav_svn.passwd
AuthzSVNAccessFile /etc/svn/dav_svn.control
Require valid-user
</Location>
</VirtualHost>
Now enable the site and start/restart Apache:
/etc/init.d/apache2 restart
Setup the initial repository with the svncreate command and make the user running the web service the owner, since they will be the user actually modifying the repository files.
svnadmin create /var/svn/myproject
chown -R www-data:www-data /var/svn/myproject
Now we can create the username/password files along with the access files.
touch /etc/svn/dav_svn.passwd
htpasswd -mb /etc/svn/dav_svn.passwd myuser mypassword
Create the access file to your repositories.
And now edit the file. You can set users using r and rw access writes. First you list the repository, and then the folder location after that for more fine grained permissions.
myuser = r
[myproject:/trunk/base/code]
myuser = rw
Now reboot the server and test access; it should start up automatically.
Maintenance and Use
The best way to use SVN over HTTPS is with Tortoise for Windows or some other tool if using Linux, like RapidSVN.
Adding Additional Users
To add more users, just run the htpasswd command linked to your dav_svn.passwd file, same as the initial configuration for users.
And now edit the access file containing the other users and defined in the Apache configuration. You can set users using r and rw access writes. First you list the repository, and then the folder location after that for more fine grained permissions.
myuser = r
newuser = r
[myproject:/trunk/base/code]
myuser = rw
newuser = rw
Backing Up the Repositories
To backup a repository, use the svnadmin dump command which will export the entire database and revisions. You can then tar up and gzip the dump file for compression, and back it up to tape or disk somewhere else. There are also incremental backups that can be done of disk/tape space is an issue.
Restoring the Repositories
Restoring the SVN database is simply rewriting all the revisions from the dump back into a database. The restore process also works well for moving an older repository over to a new one since restoring the dump into a new SVN database will update it to that version.
svnadmin load /home/svn/restoredproject < /home/backups/myproject_dumpfile
chown -R www-data:www-data /home/svn/restoredproject
chmod -R 770 /home/svn/restoredproject
Backing up Subversion to FTP
Handy little script for backing up Subversion to an FTP server.
# Variables
HOST='server.local.com'
USER='unixbackup'
PASSWD='mypass'
TIMESTAMP=`date +%m%d%Y%H%M`
FILEPRE='egsvn_'
# Backup EG repository
/usr/local/bin/svnadmin dump /usr/home/svn > /home/me/svn_backups/$FILEPRE$TIMESTAMP
# FTP backup to tape server
cd /home/me/svn_backups
ftp -n $HOST > /tmp/ftp.worked 2> /tmp/ftp.failed
<<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
binary
put $FILEPRE$TIMESTAMP
quit
END_SCRIPT
# Remove old files
rm /home/me/svn_backups/*
# Exit
exit 0
Subversion – Installation, Configuration, and Use
Operating System: OpenBSD 4.4
Installation
First grab the necessary compiled packages from OpenBSD.
pkg_add db-4.6.21.tgz neon-0.26.2.tgz
Then get the Apache source code for the HTTP server, configure and install. Use a 2.2.x version.
http://www.gtlib.gatech.edu/pub/apache/httpd/httpd-2.2.x.tar.gz
tar zxvf httpd-2.2.x.tar.gz
cd http-2.2.x
./configure --with-included-apr --with-berkeley-db=/usr/local --enable-shared=yes --enable-dav --enable-so --enable-rewrite --enable-ssl
make
make install
Next get the newest Subversion source code, configure and install.
wget subversion-1.5.x.tar.gz
tar zxvf subversion-1.5.x.tar.gz
cd subversion-1.5.x
./configure --with-apr=/usr/local/apache2/bin/apr-1-config --with-apxs=/usr/local/apache2/bin/apxs --with-neon=/usr/local
Add the proper user to run the httpd daemon
Configuration
Setup the initial repository with the svncreate command and make the user running the web service the owner, since they will be the user actually modifying the repository files.
svnadmin create /home/svn/myproject
chown -R _apache2:_apache2 /home/svn/
Now edit your main httpd.conf file in /usr/local/apache2/conf/ to read these changes. They're not all in the same place, just scattered throughout the file. The first two changes should already be there after installing the Subversion source, just require slight modification. The last "location" change you'll need to add manually. You'll see the dav_svn* files in there, we'll get to those next.
LoadModule authz_svn_module modules/mod_authz_svn.so
...
User _apache2
Group _apache2
...
<Location /svn>
DAV svn
SVNListParentPath on
SVNParentPath /home/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/svn/dav_svn.passwd
AuthzSVNAccessFile /etc/svn/dav_svn.control
Require valid-user
</Location>
Now we can create the username/password files along with the access files.
touch /etc/svn/dav_svn.passwd
htpasswd -mb /etc/svn/dav_svn.passwd myuser mypassword
Create the access file to your repositories.
And now edit the file. You can set users using r and rw access writes. First you list the repository, and then the folder location after that for more fine grained permissions.
myuser = r
[myproject:/trunk/base/code]
myuser = rw
Naturally you'll want to lock this service down with SSL and possibly make it available outside the network. To simply create a self-signed certificate and add it to Apache, do the following.
openssl req -new -key /etc/ssl/private/svnserver.key -out /etc/ssl/private/svnserver.csr
openssl x509 -req -days 365 -in /etc/ssl/private/svnserver.csr -signkey /etc/ssl/private/svnserver.key -out /etc/ssl/svnserver.crt
Now add the lines in the httpd.conf file in /usr/local/apache2/conf/ just about the Location setting.
SSLEngine on
SSLCertificateFile /etc/ssl/svnserver.crt
SSLCertificateKeyFile /etc/ssl/private/svnserver.key
Edit the rc.conf.local file in /etc/ to turn on Apache.
And then edit the rc.local file to auto start Apache.
if [ X"${apache2}" == X"YES" -a -x /usr/local/apache2/bin/httpd ]; then
/usr/local/apache2/bin/apachectl start &
echo -n " apache2";
fi
As well as the shutdown file rc.shutdown to kill the process.
if [ X"${apache2}" == X"YES" -a -x /usr/local/apache2/bin/httpd ]; then
/usr/local/apache2/bin/apachectl stop &
echo -n " apache2";
fi
Now reboot the server and test access; it should start up automatically.
Maintenance and Use
The best way to use SVN over HTTPS is with Tortoise for Windows or some other tool if using Linux, like RapidSVN.
Adding Additional Users
To add more users, just run the htpasswd command linked to your dav_svn.passwd file, same as the initial configuration for users.
And now edit the access file containing the other users and defined in the Apache configuration. You can set users using r and rw access writes. First you list the repository, and then the folder location after that for more fine grained permissions.
myuser = r
newuser = r
[myproject:/trunk/base/code]
myuser = rw
newuser = rw
Backing Up the Repositories
To backup a repository, use the svnadmin dump command which will export the entire database and revisions. You can then tar up and gzip the dump file for compression, and back it up to tape or disk somewhere else. There are also incremental backups that can be done of disk/tape space is an issue.
Restoring the Repositories
Restoring the SVN database is simply rewriting all the revisions from the dump back into a database. The restore process also works well for moving an older repository over to a new one since restoring the dump into a new SVN database will update it to that version.
svnadmin load /home/svn/restoredproject < /home/backups/myproject_dumpfile





