Setting up SVN on MediaTemple Hosting

We finally set up our SVN on a MediaTemple grid server and there are a few tricks along the way that might help you set up yours.

For those that are unfamiliar with it, Subversion is a version control system that keeps track of current and previous versions of files. We use it mostly for developing web applications across multiple systems as it makes it very easy to work from different machines anywhere.

We wanted our setup to accomplish a few simple tasks:

  • Maintain a copy of our source code in a single, off-site repository.
  • Be able to easily download the current-state of any files to our laptops and desktops.
  • Be able to update the entire live website with a single file check-in command.

So without further ado, here's how to get started:

First, you have to enable SSH access on your administrator account. Log in to your MediaTemple account center and go to Server Administrator in your Controls. Make sure the SSH Option is set to "Enabled."

Enable SSH

Just a quick note before we get to the commands, the next steps make a lot of use of 3 key variables: your primary domain, your administrator username, and your grid identification number.

Primary Domain (herein,
The primary domain is usually the domain you first signed up with. In this example, it will be called "" which means do not use the leading "www."

Administrator Username (herein, username)
As of the writing of this article, the default administrator username appears to match the primary domain (i.e. "") but for some legacy users it may be something like "". Whatever yours is, you'll want to make sure to use the entire name. To figure out what yours is, go to your controls and click "Server Guide" you'll find it under FTP -> Admin Username.

Grid ID Number (herein, #####)
If you don't know your grid id number, you can find it under "Server Guide" in your account center controls. It is the 4 or 5 digit number in your Primary Access Domain: (ignore the initial 's').

Next, you're going to log in to your grid server using SSH. To do that, you need to open up a Terminal window (/Applications/Utilities/, or using a client like PuTTY if you're on Windows, and type the following command:


Type in your administrator password when prompted (not the same thing as your Account Center password). You'll get a welcome message if you did it right, and now you're logged in to your server.

Next, we're going to make a directory to collect your repositories in (in case you, like us, want to track multiple projects separately). Feel free to change out the last bit, "svn_repos," to whatever folder name you wish to use to collect them in. (For simplicity sake, don't use any space characters!)

mkdir /home/####/data/svn_repos
cd /home/####/data/svn_repos

Ok, now you're in your svn_repos directory. Time to make your SVN repository (it's easier than it sounds). Luckily for you, SVN comes preinstalled on your server. The repository we're making is going to manage our entire website so we're actually going to name it "" you can name yours anything you like but if you want to update your site with a single checkin, we advise you do the same.

svnadmin create --fs-type fsfs

The bit about "--fs-type fsfs" just tells SVN to use a filesystem type that (mt) supports. You're done with your server for now, be sure to logout.


Now that your repository is created, it's time to do a checkout on your local machine.

This part of our tutorial is done using the command line version of SVN for Mac that is available from CollabNet (link). You'll want to get the "Universal Subversion Binaries for MAC OS X" download and install it.

If you're using Windows you'll probably be using a graphical client like Tortoise SVN. Unfortunately we don't have step-by-step for you right here, but if you follow along you can probably figure out how to set up your SVN in a similar manner. If nothing else, stay tuned for the juicy server-side help at the end!

Now that you have an SVN client installed, you need to choose where you're going to keep your repository on your local machine.

Helpful Hint:
This tip is how to store your repositories with a short system path to make check-ins more painless. It is not critical to setting up your repository and you can skip it!

We sometimes use a tool called MAMP to create a local web development environment with PHP and MySQL. In order to use it, our local web files have to be stored in MAMP's htdocs folder in /Applications/MAMP/htdocs/. So we want to checkout our repository into our website folder -but- that's way too long of a folder path to type out every time we want to check in our files! Enter: the symbolic link. A symbolic link is a file that links to a folder and acts transparently as that folder.

So we're going to create a "/web" link in the root of our hard drive. Open Terminal and enter the following command (where "/Applications/MAMP/htdocs" is the real folder you want to put your repositories in and "/web" is the shortcut folder name):

ln -s /Applications/MAMP/htdocs /web

Now whenever we want to get to the folder containing our repositories, we can just use /web/repository_name instead of that long folder path!

Ok, now go into the folder where you want to checkout your repository. (Note: When you checkout your repository, it will create a folder that has the same name as the repository. Navigate to the place that you want to hold that repository folder.) We're going to use /web - replace it with your desired container.

cd /web

Now, let's do the checkout. Type the following command in your Terminal window:

svn co svn+ssh://

That's it! Your local SVN is now configured. Let's head back to the server for a moment:


Now we're going to navigate to the location we want our web files to appear when we check them in. This is NOT the same as your SVN repository in the "data" folder. Instead, we're going to go into the "domains" folder where our websites files are hosted and can be seen from a web browser. Because we're setting up our entire domain to be under version control, we're going to navigate directly into the domains folder. If you only want a sub-directory of your website to be under version control, you would navigate to its parent directory in this step.

cd /home/#####/domains

Helpful Hint:
If you're setting up version control for your entire site, you probably have some files that are currently in your website's directory. If you're not setting up version control for your entire site, you can skip this step. Otherwise, move your website's folder to a backup location:


Now, checkout a copy of the repository to this folder on your server. The syntax is a little different than before.

svn co file:///home/#####/data/svn_repos/

Helpful Hint:
If you're not setting up version control for your entire site, skip these steps. Otherwise, copy your website's files back into place:

cp -r

After copying, sometimes the permissions on the html folder can go askew. Best to run a quick chmod to make sure your file permissions stay correct here.

chmod 755 html

Now you're going to add all your website files to version control.

svn add html

You'll see a big list go by of all the files that SVN is adding to version control. When the list finally finishes and you have a prompt again, it's time to do your first check-in.

svn ci -m "Initial Check In"

This may take a while depending on how many files you have and what size they are. When it finishes, update your local machine's SVN with all these newly added files. From a separate Terminal window, navigate on your local machine and perform an SVN update.

cd /web/
svn up

The Bread and Butter of SVN on a Web Server

That's right, folks. For anyone reading this article that is new to SVN administration - this is the section that you've been waiting for. "How do I get my web server to update to the newest version when I check-in my files?" you've been wondering... Enter: hooks. Hooks are scripts that execute when a repository action occurs. For the purposes of updating a live site on check-in, we're going to use what's called a post-commit hook.

So, while SSH'd inside your server navigate to your repository's hooks:

cd /home/#####/data/svn_repos/

Make a post-commit hook with the following command:

vi post-commit

Press "i" to get vi in the "insert" mode and enter the following into the new file (you may replace "/home/#####/domains/" with the location of the checkout we did in the server-side checkout earlier. If you've been following the directions for making your whole site source controlled, this is the correct directory.)

svn update /home/#####/domains/

Press Escape to get vi out of the "insert" mode then type :wq and press enter to save and quit. Now you need to make the file executable.

chmod 755 post-commit

Finally, logout of MediaTemple.


And... You're done! Your website is ready to update live every time you commit a change to your repository. Remember, you can have your repositories checked out on multiple machines, and anytime you check-in a change from anywhere, your website will update.

I hope the above has been clear. Please forgive this verbose and convoluted tutorial, the ones I used in trying to get this thing set up seem to have left steps out which caused me a few headaches.

Basic SVN Usage on your Local Machine
Here are a few commands you may find useful when you're using SVN on your local machine.

All of these commands should be used inside the directory you want them to influence.

This will perform the initial checkout of the current version of the SVN repository and set up that repository on your local machine. You only ever need to do this once per repository on each machine.

svn co svn+ssh://

This will check-in any updated files on your local machine to the server. You can populate the "Message" field with a helpful note about what changed or leave it blank with ""

svn ci -m "Message"

This will update any old files on your local machine with the most current version available from the server.

svn up

When you create new files or folders, you must let SVN know to add them to version control. Do so with the add command (if you use a folder name in place of filename, svn will add the folder and recursively add any folders and files within it)

svn add filename

Similarly, if you want to delete a file, you must remove it from source control. This command will delete the file or folder on the local machine and on the server.

svn rm filename

Additional Resources:

5 Responses to “Setting up SVN on MediaTemple Hosting”

  1. This is great just what I've been looking for.
    I have have many projects in my mediatemple (gs) svn repo. Is there a way of updating different domains depending on which project was updated?

    Once again thanks for this excellent write up.

  2. admin says:

    Mr. Tullett,

    Absolutely - the best way to do it is to repeat this process for each domain you wish to have under svn. To recap you'll:
    - Create a repository for the domain name (or project name),
    - Do the local checkout,
    - Do the checkout to the server for that domain's folder
    - Set up the post-commit hook in the new repository

    Now, when you commit changes from each domain's folder, that project will get updated accordingly. This is how we use SVN, and it has worked out pretty well so far!

  3. Hi.

    That's great. I have done what you've said and i can now say I'm happily using it now.

    A couple of things i did differently was this which maybe of some use to other people.

    I set up my repo with trunk, branches, tags folders.

    so i did this instead

    svn co file:///home/#####/data/svn_repos/ .

    The dot (.) just tell the system to checkout into that folder the contents

    It works great.

  4. This can be a really beneficial web site. Many thanks for sharing! I've put your RSS feed into my blog site.

  5. unscreened says:

    Appreciate it!

Leave a Reply