How to Set Up Multiple Subversion Repos on MediaTemple

I’ve been busy lately with lots of side projects (including the new theme surrounding this post), and one key tool that helps keep my work organized and sane is Subversion. A while back, I discovered that my web host of choice, MediaTemple offers two ways to host Subversion repos for your own usage alongside regular web hosting: you can make use of a single Apache webserver driven Subversion repository, or configure full-blown Subversion over secure SSH tunneling. Here’s how to get the latter up and running, complete with a hosted checkout of your work that auto-updates after your commit.

Enable SSH Access

By default, SSH remoting is disabled on MediaTemple accounts, requiring you to explicitly enable it in the Server Administrator control panel section for your primary domain:

Once there, set SSH on “Enabled”, and save your changes. MediaTemple’s easy-to-use configuration tool couldn’t make this step any simpler.

Connecting and Creating a Repository

Fire up Terminal in your Applications/Utilities folder under Mac OS X, or grab the latest version PuTTY under Windows, and connect to your MediaTemple host as For example, if your site were, you would connect as follows:


The domain “” is in there twice, first because it’s part of your full username, and second to point SSH at the right server. (If your SSH client complains about not being able to connect, you can try replacing the first @ sign with its encoded version, “%25”.) Type “yes” to confirm adding to your known_hosts, if asked, then enter your administrator password to finish logging in.

Enter the following commands to switch to your “data” directory (provided by MediaTemple), and create a basic repository for your code/information:

Change directory (cd) to your data directory:
cd ../../data/

Create a “repos” directory to hold one or more repositories:
mkdir repos

Change directory to the folder you made in the previous step:
cd repos

Create a repository (replace “tests” with your desired repository name, using underscores for spaces). Letter case is important, so if you capitalize any part of the name now, you’ll have to capitalize it later when using it. The bit about “fsfs” is to use a specific Subversion database type recommended by MediaTemple — it’s the default type for newer versions of Subversion, but it’s best to put it just to be safe.

svnadmin create tests --fs-type fsfs

You can repeat this to create as many repositories as you wish inside the “repos” folder.

Log out of MediaTemple:


Checking Out Your Repository

On your local computer (not on MediaTemple), decide where you want to keep your repositories. I recommend someplace easy to get to like /workingcopies/, but a repo can go anywhere you prefer. Check out a copy of the repo you just made:

svn checkout svn+ssh:// /workingcopies/tests

Be sure to replace “1234” with your four-digit MediaTemple server ID number that can be found in your Service Activation email.

To verify everything drop a simple file into your new repository folder at /workingcopies/tests, such as test.txt, and do:

svn add test.txt followed by svn commit -m "Adding test file."

Auto-updating MediaTemple

If you have some code stored in a repository that you’d like to automatically be made available to the world, such as a WordPress theme or web application, Subversion provides various “hooks” that can be run at times like pre-commit, post-commit, etc. Subversion hooks are nothing more than scripts which you define, and get run when the applicable action occurs. Here’s how to set up an automatically updating WordPress theme repository:

Connect to MediaTemple again, using the initial ssh command at the start of this tutorial, then change directory to where you want to use this repository on your MediaTemple server:

cd ../../domains/

Check out a copy of your repository elsewhere on your server, using file:// instead of svn+ssh://

svn checkout file:///home/1234/data/repos/tests tests

Again, replace “1234” with your server ID, and also replace “tests” with your repository name (in both places). Now you have a copy of that repository on your server. Edit the hook so it gets updated automatically when you commit changes:

cd ../../data/repos/tests/hooks

Make a copy of the post-commit hook example:

cp post-commit.tmpl post-commit

Use your favorite command-line text editor the post-commit script:

nano -w post-commit

Change the entire script (below #!/bin/sh) to:

svn update /home/1234/domains/

Exit, saving changes, with Control-x, y, Enter.

Make your post-commit script executable:

chmod +x post-commit

Finally, log out of MediaTemple again:


Now, after a commit, Subversion will automatically update the repo you have checked out on your server, and your changes should be reflected almost instantly.

There’s a lot more to using Subversion, so here are some hand-picked resources to keep you going:


How to Set Up Multiple Subversion Repos on MediaTemple

11 thoughts on “How to Set Up Multiple Subversion Repos on MediaTemple

  1. Dude, first of all thanks so much for this writeup. I will be using it at some time. But most of my congratulations go to your hard work on the site. It turned out beautifully and it looks sweet.

    Cheers bro!


  2. Thanks!

    I’ve been looking for this for awhile. Just one thing, the post-commit needs to have permission to execute. so I ran “chmod +x post-commit” to set permissions and everything works like a charm.


  3. Thank you!! Much respect! I’m new to svn and I’ve been trying to get this working all night and wondering where I was going wrong!! I was missing the fact it needed to be checked out first i.e, svn checkout file:///home/1234/data/repos/tests tests Anyway, I can sleep now =) Thanks again!!


  4. Fahd says:

    Thanks for this write up. I’m trying to setup SVN on Media Temple (gs) and found your article. I followed the instructions on the MT knowledgebase but I’m confused about one part which your article kind of addresses. The instructions state that your code structure (trunk, branches, tags) goes into data/sites/wesbite and the repo is made in data/svn.

    But the data/sites is obviously not accessible from a url since its not in the domain folder. So it seems like I can use this post-commit hook to update files to the domain folder from the repo – but what I dont get is if there will be duplication with data/sites? Not sure If I’m missing something and if its possible if I could just link the repo to the domain folder (but then, it should only be whats in the trunk :S).

    I’m new to this so any help appreciated :)


  5. @Fahd:

    One of the things that confused me about SVN initially was that I thought the repo itself was equivalent to a checked-out copy on the server. Later, I found out that you need to have the repo be accessible via svn:// or svn+ssh://, but maintain a separate checkout elsewhere, and update it upon commit. Technically, it is duplication, since you’ll have the repo copy of the code and the “runnable” checked-out copy of the code, but it’s duplication you can’t get around; Subversion repos aren’t stored in such a way that you can both store AND run the code.

    For a system where you have, for example, a single repo and a single website that needs to be updated from that repo, I’d suggest the following layout:

    /home/1234/data/repos/reponame for SVN repo storage

    /home/1234/data/repos/reponame/hooks/post-commit for updating the location below upon commit
    Use a script like:

    svn update /home/1234/domains/

    For this script, remember to do chmod +x post-commit to make it executable.

    /home/1234/domains/ a checked-out copy of reponame/trunk (or reponame/tags/deployment)

    Another thing that tripped me up was thinking that the trunk/tags/branches structure came with the new repo. They do not. A new repo is a completely empty tree, and creation of trunk/tags/branches is completely optional. It’s just the agreed-upon base structure for most repos, but you aren’t forced to use it. You can do a ‘svn import’ to create them from the server command line, but I often find it’s easier to just check out the repo on my own machine, make the three trunk/tags/branches folders, add them, then check those in as my first commit.

    Finally, I use something like svn+ssh:// as the URL to check out a repo from that location. svn+ssh:// is nicer than straight svn:// because it’s encrypted.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s