Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • Configure Subversion with Apache and Security in 5 Easy Steps

    Posted on January 19th, 2012 phpguru No comments

    I’ve been running WampServer for years on my trusty Dell XPS running Windows XP Pro. A while back I installed Subversion and got it working with mod_dav and authz_svn to serve multiple repositories, each with their own user and group permissions. It was tricky to set up and there are some finer points that most documentation I read doesn’t address. I followed a few different web resources like this great beginners guide, but ultimately it boils down to the 5 simple steps below.

    Just recently I needed to add a new repository. I thought I had done everything right, but when I went to use it for the first time, I got the following errors:

    D:\svn\repos>svn mkdir http://localhost:8080/svn/myproject/trunk -m "Trunk"
    svn: OPTIONS of 'http://localhost:8080/svn/myproject': 200 OK (http://localhost:8080)
    D:\svn\repos>svn ls http://localhost:8080/svn/myproject/trunk
    svn: URL 'http://localhost:8080/svn/myproject/trunk' non-existent in that revision
    D:\svn\repos>svn ls http://localhost:8080/svn/myproject
    svn: Could not open the requested SVN filesystem

    If you are getting any of these common errors, this post is for you.

    When using svn over http, you have to use Apache’s configuration files to control access to each repository separately. Start by installing Apache, Subversion, and then referencing these three modules in your httpd.conf as follows:

    LoadModule  dav_module             modules/mod_dav.so
    LoadModule  dav_svn_module         modules/mod_dav_svn.so
    LoadModule  authz_svn_module       modules/mod_authz_svn.so

    Now we’re ready to begin.

    1) Add the repository:

    #> svnadmin create D:\svn\repos\myproject

    *(On Unix systems, chown -R myproject so it is writable by the user Apache runs as)*

    2) Edit your httpd.conf (or extras/httpd-vhosts.conf) adding something like this:

    <Location /svn/myproject>
       DAV svn
       SVNPath d:/svn/repos/myproject
       AuthType Basic
       AuthName "My Project SVN Repo"
       AuthUserFile c:/etc/svn-auth-file
       Require valid-user
       AuthzSVNAccessFile c:/etc/svn-acl

    3) Add the project to your svn auth file at c:/etc/svn-acl (it’s referenced in the Location directive in your Apache config.)

    yourgroupname = yourusername, user_b, user_c
    yourusername = rw
    @yourgroupname = rw

    This is what tells Apache which users and groups are allowed to access the path(s) in your repository.

    4) Give yourusername an htpasswd (and user_b and user_c)

    cd c:/etc/
    htpasswd -c svn-auth-file yourusername

    *(If that file already exists, omit the -c option)*

    5) Finally, restart Apache

    httpd -k restart

    Then you’re ready to create trunk

    #> svn mkdir http://localhost:8080/svn/myproject/trunk -m "Adding trunk"
    Committed revision 1.

    I got the errors shown above when forgetting step one or more of these steps.


  • Git Resources for Subversion Users

    Posted on June 11th, 2011 phpguru No comments

    I’ve been using Subversion for years, but lately I’ve been thinking it’s time to get into Git more. Plus, A lot of new GUI tools are out there and some of the older ones are still there, too, so maybe Git has matured enough for production use.

    Why would I want to use Git?
    Flavio sums it up quite nicely:

    What’re the advantages?
    Since Git is a distributed revision control system (while svn is a centralized one) you can perform commits, branches, merges… on your local working directory without being connected to internet. Next time you’ll be online, you will be able to “push” your changes back to the central svn server.

    In a tech video from Facebook, one of the things they mention is that their developers us Git on local workstations for managing changes, and Facebook overall uses Subversion for managing the source tree centrally. I thought it was interesting that Facebook, one of the most advanced, largest and high-powered software applications on the planet, uses both Git and Subversion. Here’s an article about Using Git and Subversion Together.

    I’ll be posting links to the resources I find here.

    Three Part Intro to Git Series

    1-2 hours • First, take the Git Crash Course.

    2-4 hours • Next, read Git for Subversion Users, Part I and Git for Subversion Users, Part 2. These two articles at IBM.com give you a really good overview of the main differences between Subversion and Git.

    4-6 hours • Finally, you should read Pro Git. This is an awesome free online book about Git.

    After you complete these you should be a total Git.