SVN (or Subversion) through Apache2 on Debian based Linux Distro's. After many trials and errors and taking down my webserver a few times I finally was able to get a full on SVN Server for my main website up and running with Authentication over SSL, and here is my tale.

Read the full blog" /> SVN (or Subversion) through Apache2 on Debian based Linux Distro's. After many trials and errors and taking down my webserver a few times I finally was able to get a full on SVN Server for my main website up and running with Authentication over SSL, and here is my tale.

Read the full blog"> Setup SVN with SSL using Apache2 on Linux (Debian) | Slunked

Setup SVN with SSL using Apache2 on Linux (Debian)

Jump To:   «  1 2  View All »

by Frost

Introduction
The past few days I have been digging and diving and reading through many different tutorials about setting up SVN (or Subversion) through Apache2 on Debian based Linux Distro’s. After many trials and errors and taking down my webserver a few times I finally was able to get a full on SVN Server for my main website up and running with Authentication over SSL, and here is my tale.

The Line of Thinking
I have always wanted an SVN server for my main web server but never really had the time or motivation to figure out how to do SVN through command line (SSH) and on a Debian Linux Distro. Well the past couple days I have spent countless hours working on my main Xubuntu install getting SVN figured out and working. Then porting that over to my Server which has Debian Etch installed on it. How I wanted my SVN repository setup was what made sense to me for a web server. I stuck to the basic Tree with “trunk” and “branch” but decided to omit the “tags” since it is a website I am “versioning”. Here is the tree structure:

    | ___ branch
    |         ___ www
    | ___ trunk
    |         ___ www

This structure suited my needs perfectly, as I wanted my other developer (it is only me and one other person) to be able to setup a webserver locally with branch then once the code is working under branch copy it over to trunk. Anything in trunk could at anytime be copied to webroot via a shell script. So I have stressed many times to only copy / commit working projects / files to trunk. Since this makes sense in my mind, it may not in yours, so do what you feel is best, I just found that structure to work for my needs.

Preparing The Server
Whether you are going to be setting up SVN on your local server just for your self to keep track of projects or on your remote server there are some steps to take to setup the server, with the first one being making sure you have the packages installed that need to be installed. If you are using Debian, the aptitude package manager. Here are a list of packages that are needed (Note I am assuming you are working under Apache2):

subversion
libapache2-svn

So a simple command (seen below) can make sure you have these packages installed:

sudo apt-get install subversion libapache2-svn

Once that has been done, we need to make sure that DAV and SSL (if SSL is wanted) are enabled by doing some simple commands:

sudo a2enmod dav
sudo a2enmod ssl

If for whatever reason you need to disable a module, the opposite to a2enmod is a2dismod (dis for disable). This is much easier then manually creating the symbolic links, and I would suggest you to use it.

Now that we have our webserver prepared (sort of) to at least handle Subversion Repositories the DAV mod and SSL connections, let’s get to creating the subversion repository.

Creating the Subversion Repository
The subversion creation is really straight forward. I put my repositories under /var/svn/project_name, this is just a preference, feel free to choose where you want to put the repository, just remember the location as we will need it when we get to the VHosts file later on.

Before we get to far into the subversion, I love to create a template directory structure to do for the initial import, so here is a bash script, using a similar path to the one above to setup the structure I have outlined in this script:

cd /var
mkdir svn
cd svn
mkdir -p template/branch/www
mkdir -p template/trunk/www
									

Using the directory I stated above, here are the commands I would use to create the initial repository:

cd /var/svn
mkdir project_name
svnadmin  create project_name
chown -R www-data:www-data project_name
chmod -R g+rws project_name
svn import templates/ file:///var/svn/project_name/ -m "Initial import for structure."
									

Those commands are pretty straight forward. We need to change the owner (chown) to be www-data so Apache can effectively create / delete items to and from the repository. We also need to change the mode (chmod) to g+rws which essentially sets that any user part of the group www-data has read / write / and to set the user / group id upon execution. Viola we should have a fully working Subversion Repository (well almost fully working).

Jump To:   «  1 2  View All »

2 Comments

Leave us a comment

  • trq
    on

    Just thought I should mention that naming your htpasswd file *.authz probably isn’t the most descriptive seeing as though your not using authz in this setup.

    You should look into authz and maybe write a followup blog describing how you can use it to grant different access rights to different users on a per path basis.

    • Frost
      on

      Thanks for the comment. However, I do not know what you are talking about. I do use the .authz file and show how to create it on the second page you should see it under the vhosts declaration under the Location /svn for the DAV setup. I also go over how to generate the .authz file. As far as the name for it, I am not sure how that is not the most descriptive, but feel free to name it whatever you want. As long as it is under the vhosts declaration (if you want to make people authenticate) there should not be a problem. This is just how I set it up :)

      If this is still un-clear let me know, as I think you may have glazed over that section. Thanks for the comment.

Leave a Comment

↑ BACK TO THE TOP ↑