Getting SVN to work through Apache on MediaTemple (dv) 3.5

<p>After a few too many days of tweaking around with a MediaTemple (dv) 3.5 server, I finally got SVN (Subversion) to play nice with Apache.</p>
<p>It requires some tomfoolery, but I’ve condensed it down do a fairly simple commands.</p>
<p>First off, you’ll require the <a href=”http://kb.mediatemple.net/questions/807/%28dv%29+3.5+Tech+Specs+-+Developer%27s+Tools+package+listing.”>MediaTemple developer tools</a> and root access. So, unless you’ve already done so, log onto the <a href=”http://ac.mediatemple.net”>MediaTemple account center</a> and set yourself up.</p>
<p>Also, please note, that this tutorial assumes you already have an SVN repository created, if you don’t there’s many a tutorials <a href=”http://svnbook.red-bean.com/en/1.1/ch05s02.html”>elsewhere</a>. I’ve used vim in this tutorial, so hopefully you’re down with the lingo.</p>
reprocessSession
<p>Once ready and logged onto the server, we dive into the shell goodness:</p>
<code lang=bash>
# install yum on ze server
rpm -Uvh http://mirror.centos.org/centos/5.1/os/i386/CentOS/yum-3.0.5-1.el5.centos.5.noarch.rpm

# update the packages on your server
# this can take a while, and isn’t 100% required
yum -y update

# install subversion and mod_dav_svn, the main item missing from (dv) 3.5 servers
# You should be prompted to approve the installation of the package, so say yes when required
yum install subversion mod_dav_svn
</code>

<p>Now that Yum and all the required modules are installed we can move on to setup Apache:</p>

<code lang=bash>
# create and edit a svn.conf file which will be automatically loaded by MT’s web admin scripts
vim /etc/httpd/conf.d/svn.conf
</code>

<p>We want to load the svn modules, using the following code:</p>

<code lang=”Apache Log”>
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
</code>

<p>Cool, that should be Apache all ready, now it’s time to setup the repository. The following commands should get you on your way:</p>

<code lang=bash>
# change the directory to that of your repository
cd <path_to_repo>

# you only need to do this if you want to secure your repository
# this step isn’t required, but if skipped will result in an open repo

# htpasswd will create a user account for “<user_name>”
# you’ll be asked for a password
htpasswd -c .repoUsers <user_name>

# you can add as many others as you’d like using the following command
# htpasswd .repoUsers <user_name_b>

# now lets move through to the web root config
cd /var/www/vhosts/<domain>/conf

# lets edit the vhost.conf
vim vhost.conf
</code>
<p>Okiday, now lets add a location to the vhost.conf. By default, you won’t have one; but if you do, be sure to leave what’s there as it is.</p>
<p>This is what you’re going to add to the vhost.conf. Make sure you change the paths to match your own! Also, if you opted not to create secure the repository leave out the last 4 lines of the location code:</p>
<code lang=bash>
<location /svn>
DAV svn
SVNPath /var/www/vhosts/<domain>/repo
AuthType Basic
AuthName “Your Repository”
AuthUserFile <path_to_repo>/.repoUsers
Require valid-user
</location>
</code>

<p>BAM! Just like that your repo and Apache setup should be done and dusted! Now it’s just a matter of restarting Apache.</p>
<code lang=bash>
web
</code>

<p>You should be able to enter the url into a browser and be hit with the authentication dialogue, mine is here: <a href=”http://isnot.tv/svn” target=”_blank”> http://isnot.tv/svn</a>.<p>
<p>If you get the dialogue then you’re all done! If not, then something went FooBar, post a comment and I’ll try to help you out.</p>
<p>Enjoy!</p>