Pages

Friday, June 20, 2014

Installing and Configuring Subversion (SVN) on Ubuntu Linux

Step 1
Make sure that svn is installed on your web host.  Just ssh into your account and type
which svn
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
anon-access = none
auth-access = write
password-db = passwd
pico ~/myrepository/conf/passwd
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
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...

1 comment:

  1. DreamHost is ultimately one of the best web-hosting company with plans for any hosting needs.

    ReplyDelete