SVN: Tutorial & Best Practices
A version control system
To install SVN (Subversion) in Apache, you will need to follow these steps:
Install Apache HTTP Server: To install Apache HTTP Server on a Debian-based system (such as Ubuntu), you can use the following command:
sudo apt-get update && sudo apt-get install apache2
To install Apache HTTP Server on a Red Hat-based system (such as CentOS), you can use the following command:
sudo yum install httpd
Install the SVN module for Apache: To install the SVN module for Apache on a Debian-based system, you can use the following command:
sudo apt-get install libapache2-mod-svn
To install the SVN module for Apache on a Red Hat-based system, you can use the following command:
sudo yum install mod_dav_svn
Enable the SVN module in Apache: To enable the SVN module in Apache, you will need to edit the Apache configuration file. On Debian-based systems, this file is typically located at /etc/apache2/apache2.conf. On Red Hat-based systems, it is typically located at /etc/httpd/conf/httpd.conf.
Add the following line to the configuration file to enable the SVN module:
LoadModule dav_svn_module modules/mod_dav_svn.so
Configure the SVN repository: Next, you will need to create a directory to store your SVN repository. This directory can be anywhere on your system, but it is typically stored in the Apache document root (e.g. /var/www/html on Debian-based systems, or /var/www/html on Red Hat-based systems).
To create the repository, use the following command:
sudo svnadmin create /path/to/repository
Configure Apache to serve the SVN repository: To configure Apache to serve the SVN repository, you will need to add a configuration block to the Apache configuration file (as described in step 3). The configuration block should look something like this:
Copy code <Location /svn> DAV svn SVNPath /path/to/repository </Location>
This will enable Apache to serve the SVN repository at the URL http://your-server/svn.
Restart Apache: Finally, restart Apache to apply the changes:
sudo service apache2 restart (on Debian-based systems) sudo service httpd restart (on Red Hat-based systems)
You should now be able to access your SVN repository through Apache.
Create new Respository
svnadmin create --fs-type fsfs /mnt/svn/svnrepository
chown -R www-data. /mnt/svn/svnrepository
Configure Apache
Enable the SVN apache module: a2enmod dav_svn and make sure that HTTPS is working correctly.
DAV svn
SVNPath /mnt/svn/svnrepository
AuthType Basic
AuthName "SVN Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
SSLRequireSSL
Move project from one repository to another
svnadmin dump /svn/oldrepository > old.dump
svndumpfilter include path/to/project --drop-empty-revs --renumber-revs --preserve-revprops < old.dump > project.dump
svnadmin load /svn/newrepository < project.dump