Skip to content

Add Subversion to the XAMPP Apache Server

97subversionSubversion is a simple and popular source control system. It has the option of running as part of the Apache server. We’ll examine how to quickly get subversion up and running with the Apache server which comes with XAMPP.

  1. Download the latest subversion windows archive. Look for a file named “svn-win32-1.4.6.zip” (or with a later version number) at the bottom of the list.
  2. Unzip it to a local directory “c:\bin” and you will end up with “c:\bin\svn-win32-1.4.6”.
    • Add “c:\bin\svn-win32-1.4.6\bin” to the end of the Windows “path” environmental variable. This will allow us to run the command line subversion client and repository administration tool.
    • Warning: If you use Eclipse and the SubEclipse plugin, putting subversion in the “path” environmental variable may break the SubEclipse plugin. If this happens, just remove subversion from the “path” environmental variable and use Eclipse to perform subversion functions exclusively. Or ensure that your installed SVN version is compatible with SubEclipse; for example, SVN 1.4.6 is compatible with SubEclipse 1.2.1.
    • Also set “SVN_EDITOR=notepad.exe” to identify the default text editor to be used by the subversion command line tools.
  3. Create an initial blank repository called “svn_repos” by launching the command prompt window and running:
    svnadmin create c:\svn_repos
  4. Configure apache to use the subversion module
    • Stop the Apache server
    • Copy the apache module “c:\bin\svn-win32-1.4.6\bin\mod_dav_svn.so” into the apache modules directory “C:\xampp\apache\modules”. Go ahead and overwrite the existing “mod_dav_svn.so” file as it is from an older version of subversion.
    • Open up the apache config file “C:\xampp\apache\conf\httpd.conf”
    • Enable the subversion module by adding “LoadModule dav_svn_module modules/mod_dav_svn.so” anywhere after the existing “LoadModule dav_module modules/mod_dav.so” line. The best thing would be to add it as the last LoadModule line.
    • At the end, add a URL location (what you would enter into the browser or your subversion client) for your repository:
      <Location /repos>
          DAV svn
          SVNPath c:/svn_repos
      </Location>
    • Start the Apache server
    • You can access the repository using the URL “http://localhost/repos”. You should see a “Revision 0” header with no other data. If you get an error, check the “C:\xampp\apache\logs\error.log” file for details on the problem.
    • Note that you will need to add a location block like the above for each repository that you create with “svnadmin create”. (You shouldn’t need to do this because a repository can contain as many projects as you want.)
    • Note: we have not secured the repository so anyone can read or write to it. To secure subversion, see my followup post.
  5. Import an existing project (source code directory) into the “svn_repos” repository
    • If you have source code in a project directory like “c:\oldprojects\myoldproject”, you can import the contents of “myoldproject” into the subversion “svn_repos” repository by running this command:
      svn import c:\oldprojects\myoldproject http://localhost/repos/myproject -m "Initial import"
    • The comment “-m “Initial import”” is optional. If you don’t input it, the default subversion editor (“notepad.exe”) will appear. Add your import comment and save the file. If you close the file without making any changes, you will need to input “c” into the command prompt window to continue the import.
    • Browse to “http://localhost/repos/myproject” and you should see “Revision 1” header with the list of folders and files that have been imported.
  6. You can create a new empty project by creating an empty folder and importing it (see above).
  7. Checkout the initial “myproject” project to create a local working copy
    • Open the command line and go to the “c:\projects” directory.
    • Check out “myproject” by issuing the following command:
      svn co http://localhost/repos/myproject myproject
    • You will see a “c:\projects\myproject” directory with your imported folders or files (if you did the import step above). If you didn’t import, you will see an empty directory except for a “.svn” subdirectory; don’t touch the “.svn” subdirectory as it is used by the subversion client for bookkeeping.
  8. Inside your local working copy “c:\projects\myproject”, you can issue the following common subversion commands:
    • To update your local working copy with the latest revision from the repository:
      svn update
    • To add a new file:
      svn add newfile.cpp
    • To remove a file:
      svn rm oldfile.cpp
    • To move and/or rename a file:
      svn mv oldfile.cpp subdir/newoldfile.cpp
    • List the changes (aka status) that you have made to your working copy:
      svn st
    • To commit (aka checkin) the local working changes to the repository:
      svn ci -m "my checkin comments"

      If you don’t input the comment using the “-m” flag, the default editor (“notepad.exe”) will open to allow you to input the comment.

  9. To ignore certain subdirectories or files that you do not wish to check into subversion
    • Go to the directory containing the subdirectories or files to be ignored and run this command:
      svn propedit svn:ignore .
    • The default editor (“notepad.exe”) will open. Input the subdirectory and file names, one per line.
    • Instead of putting the exact filename, you can use a file pattern like “*.obj”.
    • Save and close the file.
    • To make this change permanent, issue a “svn ci” command.
    • You can also create a text file “ignore.txt” containing the subdirectory, filenames, and file patterns that you wish subversion to ignore, and apply it recursively to the current and all subfolders by running:
      svn propset -R svn:ignore . -F ignore.txt

Some info above derive from Ned Batchelder: Subversion on Windows quick start.

9 Comments

  1. J Jones

    Googling for this topic led me to this entry. This paper saved me a lot of frustration and time.

    I’m also finding several other entries that will help in the coming days.

    Thank you.

  2. I have a problem

    Why I can’t start the apache service when I add the

    LoadModule dav_svn_module modules/mod_dav_svn.so

    line to httpd.conf ?

    • Chanh

      There might be an error that prevents apache from starting. For example, if the module is missing from the hard drive or the module file name is mispelled in httpd.conf. I would suggest double-checking everything and also checking the apache log file at C:\xampp\apache\logs directory. Look for the error.log file to see if there are more info on why apache failed to start.

  3. Mahesh

    Thank you so much. This worked like magic. Adding the location is the key.

  4. nxhoaf

    @Permana Jayanta , i have the same problem with you, please check for suitaible version of SVN
    http://subversion.tigris.org/getting.html#windows
    and here is the very important note
    Note: Apache 2.0 and Apache 2.2 are not binary-compatible. If you plan to use mod_dav_svn be sure that you obtain the correct version for your version of Apache.
    perhaps you installed binary version, i’m too, please remove it and reinstall with .msi
    I followed it and it worked 🙂

  5. Doug

    To the person who had the modules not loading:

    That can happen if you skipped the steps on putting the svn bin directory in the path. If Apache can’t find the SVN dll’s the modules won’t load.

    Instead I copied the SVN dll’s into the Apache Bin directory. Its not as “clean”, but it allowed me to get SVN running on a USB stick.

  6. Villars Gimm

    Is this also possible on a Mac?

    • Chanh

      Hi, I haven’t tried it but I don’t see why you couldn’t do the same setup on mac os x. You may need to adjust the instructions to be mac specific though. Good luck!

Your email address will not be published. Required fields are marked *