This tutorial will show step by step how to configure Apache, how to password protect and create your first repository.
I won’t go in to details how to install but if you use Fedora, use yum. If you don’t know how to install Apache, try Google for your Linux dist.
Step 1 – Create a new empty svn repository
Make sure you are root or have root access. To create the repository use svnadmin, I will create it in /var/www/svn. Path is not important so you can go ahead and choose any path you want.
svnadmin create /var/www/svn
Step 2 – Create file structure and import to repository
In Subversion you should establish the trunk,tags and branches directory. So we will do this too. Start with creating a folder, preferably in your /tmp directory. Create a directory called svn in /tmp with 3 subdirectories called “branches”, “tags” and “trunk”.
Import those into svn with following command:
svn import /tmp/svn file:///var/www/svn -m "first import"
You will get a reply that directories been added and that you committed revision 1.
Step 3 – Authentication
You don’t want your files public so you will need to do some authorization for your svn. I’ll use the basic and store passwords in a htpasswd file. Store this file within your svn directory.
htpasswd -cb /var/www/svn/htpasswd user1 Pass1
Step 4 – Apache setup
You will need to add a virtual host setup to be able to access it from outside with your domain. You will always be able to access svn from your local file system. I will use “svn.domain.com” in this example.
<VirtualHost *:80> ServerName svn.domain.com DocumentRoot /var/www/svn ErrorLog /var/www/logs/svn_error_log <Directory /var/www/svn> AllowOverride All Options MultiViews -Indexes Includes FollowSymlinks <IfModule mod_access.c> Order allow,deny Allow from all </IfModule> </Directory> # WebDAV access <Location /> DAV svn SVNPath /var/www/svn AuthType Basic AuthName "Your message for this realm" AuthUserFile /var/www/svn/htpasswd Require valid-user # authentication <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> </Location> </VirtualHost>
Now, do a config test first before restarting Apache
service httpd configtest
Step 5 – Restart Apache
When config test says “Syntax OK” its time to restart your httpd. Try and accesss http://svn.domain.com and a authentication dialog pops up, enter your username and password. If everything works fine you should see those three directories you added earlier.
I came across a few errors when doing this
Unknown DAV provider: svn
If you get the message “Unknown DAV provider: svn”, you’re missing two important Apache modules. Edit your httpd.conf and look for these modules and uncomment
- dav_svn_module modules/mod_dav_svn.so
- authz_svn_module modules/mod_authz_svn.so
If you using Fedora, you can use yum to install those packages
yum install mod_dav_svn
Then try and restart, if those modules are working apache shouldn’t have any problems starting up.
403 – Forbidden
Make sure your Apache user, default apache has read and write access to /var/www/svn/db. Also check so the rest of the files are readable.
Activities.d can’t write on commit
Make sure that apache has full read and write access to /var/www/svn/dav and /var/www/svn/dav/activities.d
Setting up a web server
Learn how to configure a web server from home, read more