For some time now, I've wanted to have an svn set up on my shared web host similar to what we have here at civicactions.  Having to make changes on my local machine for any personal (non-civicactions client) sites, then scp those files up to my server is ridiculous -- especially since when working on client sites, I've become so used to simply commiting the changes to a repository and then updating that repository on the server side.  All that said though, I kept putting off the svn set up because as a simple drupal and civicrm developer, I was afraid that a system admin task like setting up svn would be too involved and maybe a bit over my head.  Turns out, I should've done it months ago.  It's crazy easy!

Step 1

Make sure that svn is installed on your web host.  Just ssh into your account and type

which svn
Lucky for me, my shared host already had svn installed at /usr/bin/svn.  If you're not so lucky, then you'll need to install svn yourself.  Depending on your system and your set up, there are multiple ways to do this.  For this and all other svn questions, I'd recommend the svn red book.  One of the finest examples of open source software documentation I've ever seen.  Extremely helpful.  Of course, if you're on a shared host like me, then you probably won't have the access you need in order to install svn.  In that case, contact your system administrator and ask them to install svn for you. 

Step 2

Create your repository. Once svn is installed on your host, you can proceed with the repository set up.  Just ssh into your server and create a repository wherever you'd like it.  In my case I put my repository in my user directory.  I would've preferred to have it in the root directory, but because it's a shared host, I don't have write access to anything outside of my user directory.  To create the repository, issue the following command:

svnadmin create ~/myrepository

Step 3

Create your SVN user: Now that your repository is successfully set up, you'll need to create an svn user.  Simply open the svnserve.conf file in the editor of your choice:

pico ~/myrepository/conf/svnserve.conf
and add the following:
anon-access = none
auth-access = write
password-db = passwd
Now you'll need to create a password file:
pico ~/myrepository/conf/passwd
Add a line in that file for your user in the format =
exampleuser = examplepassword

Step 4

Create a hierarchy for your repository: This step is optional.  It's not needed in order to get svn to work properly, but if you're planning on keeping multiple projects under revision control, then it's a good idea to get organized before you start importing those projects.  In my case, I'll be working on upgrading one of my sites from Drupal 5 to Drupal 6 soon (yes, I know...  I've been putting that off too.), so I wanted a trunk for the Drupal 5 project and a trunk for the soon-to-be-upgraded Drupal 6 project.  You can create directories in your repository in almost the same way you create them on your file system, using mkdir.  You'll need to use svn's mkdir command though like so: NOTE: Relative paths don't seem to work here.  svn doesn't seem to like '~', so remember to start with the root directory (so it'll look like 'file:///root/rest/of/path...'.  With three forward slashes.

svn mkdir file:///path to your repository/myrepository/d5
svn mkdir file:///path to your repository/myrepository/d6
Now you're almost there.  Next, you'll need to import the files you want to keep under version control into your new repository.  Do that with the svn import command.
svn import /path to your project/myD5project file:///path to your repository/myrepository/d5
svn import /path to your project/myD6project file:///path to your repository/myrepository/d6

Step 5

Run the svn server as daemon:

svnserve -d

Step 6

Check out your repository onto your local machine: Back on your local machine, go to where you keep your nerd stuff.  In my case it's in ~/workspace.  Then use the svn co command to check out a copy of your project.

cd ~/workspace
svn co svn+ssh://username@hostname/path to repository/myrepository/d6

Step 7

Go get a tasty beverage and rest comfortably in the knowledge that you'll never have to scp another file again.  Well, except for maybe the occasional mysqldump file...