How to: Install Subversion on a (mt) Server
October 11th, 2007
A few weeks ago I set out to install subversion (svn for those not in the know) on my (mt) (dv) 3.0 server. More than a few Google searches turned up a few different sites and the (mt) knowledgebase. The problem was that there wasn’t one single post that took me through the full process. Thankfully I have some very smart friends that helped me out.
Requirements
In order to set up svn on your server you’ll need a few things. Anyone with the (dv) 3.5 server can skip the installation instructions. SVN is installed with the developer tools on (dv) 3.5 servers.
- root ssh access — to get this just fill out a support request with (mt) and let them know what you want the password to be
- Terminal or other ssh app
- Your servers IP address — obviously
- Some patience and understanding of *NIX commands
The rest of this little tutorial may seem a little simple for some but I want to make sure I don’t lose anyone that is just getting started with svn.
Getting Started
Once you’ve got ssh access, the first thing you’ll need to do is log in to your server with ssh root@12.34.56.78. After you’ve logged in, the prompt will change to indicate that you’re working on your server now.
Installing svn
Now we’ve got to download svn to our server. There are a couple different ways out there, one being to install and use yum and the other being to manually download svn to our server and make the installer. I decided that downloading and making the installer was a better way to go. So, in order to do that just follow these steps:
- Make sure you’re at the root directory (prompt should say
[root@12.34.56.78 ~]#or something similar) -
Download svn source from this list using
wget.For Example:
wget http://subversion.tigris.org/downloads/subversion-1.4.5.tar.bz2
-
Download the dependencies from the same list as above with
wgetwget http://subversion.tigris.org/downloads/subversion-deps-1.4.5.tar.bz2
- Now we’ve got to extract the downloaded files with
tar xjvf subversion-1.4.5.tar.bz2and
tar xjvf subversion-deps-1.4.5.tar.bz2 - Change directories to the subversion folder we just extracted with
cd subversion-1.4.5 - Make the installer and install svn with these commands (there will be lots of text scrolling through the window after each command so be sure to wait for the prompt before entering the next command command):
./configure -with--apxs=/usr/sbin/apxs make make install
You’ve now successfully installed the svn software on your server. Next up is configuring svn and your server so you can use svn for your projects.
Subversion and Apache
We need to make sure the svn module is being loaded each time Apache is started in order for svn to work properly in this type of setup. In order to do that we’ll have to open up the httpd.conf file using vi.
vi is pretty tricky if you don’t have any experience with it so I’ll do my best to explain exactly what you’ll need to do. If you’re not sure about the following steps find someone who’s got some experience to help you out.
We can use vi /etc/httpd/conf/httpd.conf to load the proper file into the vi editor. There should be a list of modules that get loaded when Apache starts and we’re looking for one called dav_svn_module and another called authz_svn_module. Make sure both are listed and neither line begins with a hash (#) mark.
Setting up the Subdomain
Out of all the steps in this little runthrough this is the part I’ll be the most general about since it’s very straightforward and easy.
You’ll need to decide where you want your repositories to live. Most people, myself included, like to create a subdomain on our servers for svn. The subdomains, in most cases, are simply svn.domainname.com. You’re more than welcome to use the main domain and simply keep your repository in a location like yoursite.com/svn/. Either way you’ll need to know the full path to where you’d like to store your repository.
To set up your subdomain, use the following steps:
- Log into your Plesk admin
- Select the domain you’d like to create a subdomain for
- Once you’re on the domain admin page there will be an icon for subdomains, select that
- Select “Add New Subdomainâ€
- Choose your name for this subdomain and also choose to “Create a separate FTP user account for this subdomain†(and enter a username and password for it)
- Save this subdomain and check that it’s working by going to it in your browser
Deciding on a Repository Structure
The next step is to set up the heart of svn, the repository. But, before we do that you need to put a little bit of thought into how you’d like to work with svn and it’s repositories. I created and removed various repositories about five or six times before I finally settled on how I wanted to set it up.
What you’ll need to decide is whether you’d like one repository for all of your projects and websites or have a separate repository for each project/site. In the end I went with a mix of the two, for my larger sites I have one repository for the site, and for the Screenflicker umbrella I’m using one repository with different branches.
Much more detailed thoughts and explanations can be found in the Strategies for Repository Deployment chapter of the Subversion book.
Creating the Repository
Now that you’ve figured out how you want to deploy your repositories, lets create one. The first step is creating a folder to hold the repository. While still in your Terminal application and connected to your server use the mkdir command to create a new directory, for example:
mkdir /var/www/vhosts/yourdomain.com/subdomains/svn/httpdocs/repo/
When the directory is created you’ll need to give it the proper permissions. For this you can use the chmod command like so:
chmod 0777 /var/www/vhosts/yourdomain.com/subdomains/svn/httpdocs/repo
Still with me? Good, cause now you get to create the repository. The code is simple enough now that you’ve laid out the groundwork. All you need to do is type:
svnadmin create /var/www/vhosts/yourdomain.com/subdomains/svn/httpdocs/repo
(substitute the path to your repo folder if you chose a different location).
Securing the Subversion Directory
Now that svn is set up, we’ll need to secure the directory so it’s a little more private — wouldn’t want to let everyone out there have a peek at what you’re doing in svn would you?
For this we’ll need to use the vi editor again to open the vhost.conf file with:
vi /var/www/vhosts/yourdomain.com/subdomains/svn/conf/vhost.conf
This file is probably empty so we’ll need to insert some new lines. In order to do that, hit the “i†key. Now add the following text:
#svn.yourdomain.com -- vhost.conf file <location /> DAV svn SVNPath /path/to/repo/ AuthType Basic AuthName "Your Domain Subversion Repository" AuthUserFile /etc/svn-auth-file Require valid-user </location>
Be sure to substitute /path/to/repo/ with the proper path to where you’ve created your repository, like you’ve done in the previous steps.
Save the changes to the vhost.conf file and exit out of vi by hitting the “esc†key and typing :x (followed by “Returnâ€).
Now you just need to add the user that you will use to authenticate against the vhost.conf file. To do that run the following command and choose a password when prompted to:
htpassword -c /etc/svn-auth-file USERNAME substituting USERNAME for your username of choice.
Restart the Server
The final step is to simply restart your server. If you’d like to use /usr/local/psa/admin/sbin/websrvmng -a -v to restart Apache or you’d rather log into Plesk and restart the server that way, it’s completely up to you.
Either way, once you’ve restarted the server, visit your new svn URI via the browser, using the username and password you created in the final step when prompted, to see that it’s working. Of course, you won’t see any files but you should get a message that you’re looking at a repository and what version of Subversion is running.
The only thing you’ve got left to do is import some files and get to work on your projects.
October 24th, 2007 at 8:52 am
Hey, I would I get subversion working if I used this confi. http://mydomain.com/svn instead?
October 25th, 2007 at 10:10 am
Yes, you’d just need to set the appropriate path when you’re creating the repository.
Once you’ve got Subversion installed on ther server the repositories can be put anywhere pretty much. It just makes more sense to put them in obvious places that you’ll remember ;)
November 21st, 2007 at 12:20 am
Thanks for the tutorial. I just got a DV and was looking for some guidance on setting up svn.
Btw, you may want to change the following ‘htpassword -c /etc/svn-auth-file’ to ‘htpassword -cm /etc/svn-auth-file’ as it will store the password in MD5. Probably uneccessary, but it adds an extra layer of security.
November 26th, 2007 at 4:18 pm
Thanks for the detailed tutorial. I was wondering if I have to use root to do all the svn stuff on the MT dv 3.0 setup. My regular domain shell access does not have any svn* commands.
November 26th, 2007 at 4:30 pm
Dave: Yes, you’ll need to ssh in as root to install svn. Once it’s installed, the commands should be available to everyone that has been given access.
December 24th, 2007 at 12:39 pm
Hi Mike
i have followed your tutorial on how to install svn but i have a small issue
i dont see this in my httpd.conf file (dav_svn_module & authz_svn_module)
could you email me back with more informaition on were to put this if its not included in your httpd.conf file
Cheers
Harry
————————————————
Subversion and Apache
We need to make sure the svn module is being loaded each time Apache is started in order for svn to work properly in this type of setup. In order to do that we’ll have to open up the httpd.conf file using vi.
vi is pretty tricky if you don’t have any experience with it so I’ll do my best to explain exactly what you’ll need to do. If you’re not sure about the following steps find someone who’s got some experience to help you out.
We can use vi /etc/httpd/conf/httpd.conf to load the proper file into the vi editor. There should be a list of modules that get loaded when Apache starts and we’re looking for one called dav_svn_module and another called authz_svn_module. Make sure both are listed and neither line begins with a hash (#) mark.
January 6th, 2008 at 11:50 am
Harry: The dave_svn_module and authz_svn_module might be shortened to dave_svn_mod and authz_svn_mod. Also, they can only be added to the file if they’ve been installed properly—not seeing them in the httpd.conf file means they probably haven’t been installed.
February 20th, 2008 at 12:17 pm
FYI, if you are installing SVN on the new (dv)3.5 you shouldn’t use the version of apr and apr-util included in the dependencies, as they will not work properly with Apache 2.2. Instead you should compile with the -apr and -apr-util options pointing to /usr/bin. This will use the proper version of apr and will work.
February 20th, 2008 at 4:45 pm
Thanks for the heads up. I haven’t upgraded to the (dv) 3.5 and I’m not sure I will in the near future. Very good to know though.
March 17th, 2008 at 10:28 am
If you’re installing SVN on the new (dv) 3.5, you are probably wasting time like I did. SVN comes part of the Developer Tools on the new (dv) 3.5:
http://kb.mediatemple.net/article.php?id=807
Go to your account center, select your domain, find “Root Access & Developer Tools” and install the developer tools.
March 17th, 2008 at 9:44 pm
dotjay: Seems you’re correct. SVN is installed with the developer tools for (dv) 3.5 servers (I still haven’t upgraded yet).
March 21st, 2008 at 4:42 am
Thanks for the tutorial!
I am running a DV 3.5 server so I started at the
“Subversion and Apache” section but couldn’t see the 2 modules that should have been in the httpd.conf. I continued the tutorial anyways (thinking that maybe the 3.5 was different and didn’t need it) but then got stuck right at the end when I had to restart apache.
Syntax error on line 3 of vhost.conf
Unknown DAV provider: svn
This is related to the 2 modules I couldn’t find so I gave up :) Maybe 3.5 is different in these instructions also?
Would really appreciate it if yourself or someone here could explain what to do next! I’ve got svn so all I need to do is get the repo I set up as per your tutorial working with apache? I find it strange that MT don’t even include a tutorial in their knowledge base but there’s one for the Grid servers?
This is the version I have:
svn, version 1.4.2 (r22196)
compiled Mar 14 2007, 20:55:55
Thanks! i’ve got svnX and subversion installed on my mac also, just need to get that repo sorted :)
March 21st, 2008 at 7:32 pm
Andrew: Based on what I know of the (dv) 3.5, you probably don’t need to do the “Subversion and Apache” section. I’d think, if (mt) is including svn on the server, the conf should be set up already.
Since the error is on line 3 of your vhost.conf file I’d suggest you comment out or remove that line from the file. The
dav_svn_moduleisn’t installed so we shouldn’t ask it to load.March 21st, 2008 at 7:57 pm
Hi Mike,
I did comment out that line in the end, but when I restarted apache I received another error about the SVN path.
“Invalid command ‘SVNPath’, perhaps misspelled or defined by a module not included in the server configuration”
I’ll have another go actually, I more than likely entered the wrong path, thanks
March 21st, 2008 at 8:04 pm
Andrew: It looks like the problem is how the vhost.conf file is setup. This probably has something to do with how (mt) has svn set up on the (dv) 3.5. Since I haven’t upgraded I’m not sure what the proper answer is. I would suggest creating a support ticket to ask for a little help. Sorry I couldn’t help more.
March 21st, 2008 at 8:25 pm
Mike, no problem, you’ve pushed me in the right direction. The repo is definately set up, just having apache troubles. Mind you, I’ve just discovered this article below and “svnserve” which seems like an alternative (have no idea what this is yet).
http://davidseah.com/blog/installing-subversion/
Will post back with how it went (after I make a snapshot, just in case!) Something always seems to go wrong with I’m twiddling with things :)
Thanks again
March 21st, 2008 at 8:46 pm
Actually that article is a bit old and it’s probably changed quite a bit since then but he did put an update on it. i guess I’ll dig in some more on this svnserve thing
April 5th, 2008 at 9:14 am
FYI, the 3.5 ships with version 1.4.2, so if you want the latest tag (1.4.6) you will have to install.
April 5th, 2008 at 9:26 am
Also, I just realized that I don’t think the 3.5 ships with mod_dav_svn or mod_authz_svn (I can’t remember, so I may be wrong). Andrew, this may be the reason why you are getting errors. Have a look in /usr/lib/httpd/modules to see if they are there. If you do decide to install the newest version, see my previous note about apache 2.2 and apr.
October 22nd, 2009 at 8:01 am
We wrote a similar article for the DV 3.5 servers, enjoy : http://www.debuggeddesigns.com/blog/view/how-to-setup-a-subversion-svn-repo-on-a-media-temple-dv-3.5-server