VPSNext


Go Back   Your VPSNext Community > Programming / Other > General Linux

General Linux Are you a Linux fan or just a guru. Talk about Linux and all of the ideas you may have about it here. We’re all looking for more knowledge about the world's best open source operating system, so let's share your happy times and bad times here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-20-2009, 11:41 PM
lhridley lhridley is offline
Junior Member
 
Join Date: May 2009
Posts: 7
Question Setting up Subversion Repositories accessible via Apache

Your VPSNext VPS has built-in support for Subversion, laying the groundwork for setting up and hosting your own repositories; however, the only option provided on your server is utilization of svnserve, the built-in server included with Subversion.

If you are only setting up one repository, this will most likely work fine; however, if you are a reseller interested in providing an SVN option to your clients, or you are setting up multiple repositories that will have different authorization controls, using Apache to access your repositories makes much more sense. Each repository can have its own authorization process, utilizing different password files (if it is password protected) for downloads and commits for each one. Plus you don't have the additional overhead of running an additional process, taking up precious RAM.

Setting up your Apache server and Subversion to function properly is a fairly involved process that will necessitate you being comfortable working at the command line; however, I've tried to outline the process I went through as detailed as possible, and tell you where to find everything that you need.

The process I'm walking through here sets up Apache and Subversion, and establishes access to a Subversion repository with access controlled by the HTTP Authorization process.

Step 1: Determine which versions of Apache and Subversion are running on your server
  • Log into your server via ssh using the access information provided by VPSNext when you signed up
  • Issue the following command to find out your Subversion version: svn --version
  • Issue the following command to find out your Apache version: httpd -v
  • As of this writing, I had updated my software, and was running Apache version 2.2.11, and Subversion version 1.5.6.
Step 2: Get the Subversion source code
  • This can be downloaded at subversion.tigris.org. Obtain the tarball file for your version (I'll use 1.5.6 as an example here) and download it to your server. For the purposes of this example, we will establish /root/subversionsource as our working directory. Change your working directory to /root/subversionsource and type in the following at the command line to obtain the tarball file for Subversion: curl -O http://subversion.tigris.org/tarball...n-1.5.6.tar.gz. Unpack the tarball by typing in: tar zxvf subversion-1.5.6.tar.gz -- followed
    by: cd subversion-1.5.6
Step 3: Get the Apache Portable Runtime libraries
  • Download the Apache Portable Runtime libraries (we're grabbing version 1.2) by typing in the following commands:
  • Configure the libraries by typing in the following commands:
    • cd /root/subversionsource/subversion-1.5.6/apr
    • ./buildconf
    • cd ../apr-util
    • ./buildconf
    • cd ..
    • You should wind up in the subversion directory with the source files
Step 4: Start compiling Subversion
  • Run the configure script by typing in: ./configure --with-apxs --disable-mod-activation
  • The above command will compile subversion with Apache module support, but will stop short of modifying the Apache configuration file to include these two modules. There will be additional work to do before you are ready to do that.
  • You will get several messages, but should compile without error. Then complete the compile process by typing in: make && make install
  • When this process has completed successfully, you should find two new module files in your /usr/local/apache/modules directory: mod_dav_svn.so and mod_authz_svn.so
Step 5: Create some supplemental apache configuration files with your configuration changes
  • EasyApache uses preconfigured commands to build Apache for your server; however, you cannot make the configuration changes you need in EasyApache. There is a way to make these changes -- certain supplementary configuration files will not be touched by EasyApache if you should rebuild your configuration via that method, or upgrade your Apache server. We're going to take advantage of those files for our purposes.
  • Create a file called /usr/local/apache/conf/includes/svnchanges.conf that includes the following instructions:

    • DAV svn
      SVNPATHAUTHz off ## turns off svn authorization process
      SVNPath /path/to/svn/repository
      AuthType basic ## uses HTTP Authorization
      AuthName "My Version Repository"
      AuthUserFile /path/to/users/file
      Require valid-user

  • Create a user file that contains usernames and passwords that will be used to access the Subversion repository. This file is the same as the one designated above in the following statement: AuthUserFile /path/to/users/file
    • htpasswd -c /path/to/users/file username
    • You will be prompted for a password for the username provided above, and asked to confirm that password. At that time the username and password will be added to the password file located at the above location.
Step 6: Modify your main Apache configuration file in two places:
  • First, open /usr/local/apache/conf/includes/pre_conf_2.conf and add the following lines and save it (this file will get loaded at the beginning of the apache configuration file via an include statement that already exists):
    • LoadModule dav_svn_module modules/mod_dav_svn.so
    • LoadModule authz_svn_module modules/mod_authz_svn.so
  • Next, open /usr/local/apache/conf/includes/post_virtualhost_2.conf and add the following line and save it:
    • #Includes the location of the subversion configuration file
    • Include "/usr/local/apache/conf/includes/svnchanges.conf"
Step 7: Stop and Restart Apache
  • apachectl -k graceful-stop
  • apachectl -k graceful
Viola! You should now have a subversion repository accessible via Apache instead of using svnserve. You can delete the working directory set up in step two at /root/subversionsource; it is no longer needed. However, if you should upgrade your Subversion software or your Apache software, you will need to download your new subversion source files and/or recompile the apache modules you created in the process, mod_dav_svn.so and mod_authz_svn.so

Note: This subversion repository will be available to all virtual hosts on your server. If you want to set up a repository for a specific virtual host, create the repository using the svnadmin create command. Once you have done that, take the configuration data used in step 5 and create a file located at: /usr/local/apache/conf/userdata/std/2/[username]/[domainname.com]/*.conf . Files at this location are automatically included in the Apache Configuration file when Apache is started. Stop and restart Apache.

A good resource for configuring Subversion repositories is: Practical Subversion, 2nd Edition (Apress Publications) by Daniel Berlin and Garrett Rooney.


Last edited by lhridley; 06-21-2009 at 12:24 PM. Reason: subversion, apache
Reply With Quote
  #2  
Old 06-21-2009, 01:03 AM
lhridley lhridley is offline
Junior Member
 
Join Date: May 2009
Posts: 7
Default Re: Setting up Subversion Repositories accessible via Apache

Correction to the above post, Step 5, bullet 2:

  • Create a file called /usr/local/apache/conf/includes/svnchanges.conf that includes the following instructions:
Code:

  <Location /svn>
  DAV svn
  SVNPATHAUTHz off ## turns off svn authorization process
  SVNPath /path/to/svn/repository
  AuthType basic ## uses HTTP Authorization
  AuthName "My Version Repository"
  AuthUserFile /path/to/users/file
  Require valid-user
  </Location>

Last edited by lhridley; 06-21-2009 at 01:08 AM.
Reply With Quote
Reply

Tags
apache, subversion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 03:15 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Copyright 2008 VPSNext. All rights reserved.