How To Set Up An SVN Repository In 7 Simple Steps
on
How To Set Up An SVN Repository In 7 Simple Steps
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 svnStep 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 ~/myrepositoryStep 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.confanon-access = none
auth-access = write
password-db = passwdpico ~/myrepository/conf/passwdexampleuser = examplepasswordStep 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/d6svn 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/d6Step 5
Run the svn server as daemon:
svnserve -dStep 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/d6Step 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...
Thank you for writing this, I was really looking for it. So far I have only used on Windows SVN without command line but mouse, right click left click to checkout or commit etc and only for local development never tried at hosting company account.
I wish you would have created a screenshot based version.
Info may be helpful to you:
a. when I searched your page was in top 6 on google
b. I can't see this specific article/post at any other web page
c. What hosting company you did this svn stuff, mine is Godaddy
d. I often get the development by myself or independent contractor so want to keep track using svn type tool/process
SUGGESTION:
You should keep captcha right below the text area, I missed to see it or just hit enter
Thank you.













I did this a few years ago, not on a shared hosting account but on a VPS I have at Slicehost. Slicehost has an amazing collection of well-written articles on all kinds of sysadmin and LAMP topics. With their articles on Subversion I was able to get my repo up and running easily.
That series of articles will lead you through the process and give you a bit more detail about security, multiple repositories, and while very easy to follow, explain some of the 'why' behind the 'how'.
Here are some slides from a presentation a colleague and I did on Git and SVN a month or two ago: Version Control with SVN and Git.
However, if I were doing this now for my own use, I would probably use Git instead of svn.