Creating A Subversion Repository

I am in the process of creating a new repository and thought I would document my steps. This may help some of you build a repository of your very own. All you need is a Linux Server with subversion installed. Of course, Linux is not necessary, but that is what my installation uses. Also, the steps below are the steps that I have taken and some of you may have a more "streamlined" process since there is always more than one way to skin a cat. If so, please post a comment and help me out with my way of building a repository.

Steps to Creating a Repository:

    (From the Linux server)

  1. Log into Linux via terminal ( putty terminal works nice ) and log on as sudo.
  2. Browse to the repository location of your choice. My location for the one I am creating is /var/www/svn/private
  3. Type at the sudo access prompt (#:) -> "svnadmin create yourRepositoryName"
  4. I do a chown to www-data at this point so: -> "chown -R www-data:www-data yourRepositoryName" ( suversion is very particular and many times, problems arise because of permissions. This is important when creating hooks to an auto svn update on the checkout of your site folder)
  5. That's pretty much it, but in order to actually start using the repository you need to create a folder structure. I will document the steps that I take but keep in mind that I am now changing to a windows machine since that is where I do my development.
    (windows client side)

  6. You can checkout the repository on your local by creating a folder on you machine. I then use a program called tortoise svn and after creating the folder I right click on that folder and do a svn checkout. You will be asked the url of the repository. An example of this would be https://svn.domain.com/private/yourRepositoryName and submit.
  7. On the local machine I create the trunk, branches and tags folders.
  8. Select all folders created above and do a right click -> add
  9. Select all folders created above and do a right click -> Commit
  10. Now that my structure is created, I move back to the Linux server in order to check out the trunk folder in the /var/www folder. This is where I will be serving the website from.
    (Linux side)

  11. Go to the webroot, in my case /var/www.
  12. I will be checking out the trunk folder of the repository. Because my www folder is on the same physical machine as my repository the command that I will use for this is -> "svn checkout file:///var/www/svn/private/yourRepositoryName yourWebFolderName". This will create the folder for you so you don't have to create the folder first.
  13. Once again, because of the strict nature of permissions, I do a: -> "chown -R www-data:www-data yourWebFolderName"
  14. Creating a subversion hook is a pretty important step for an automated overall setup. The hook is found inside the repository in the hooks directory inside your repository.

  15. copy the post-commit.tmpl to post-commit. -> "cp post-commit.tmpl post-commit" ( if you don't copy the template to a non-template, it will never work.)
  16. add the following line to the end of post-commit file: "usr/bin/svn update /var/www/youWebFolderName.
  17. Now all you have to do is change the post-commit file to be executable by doing a -> "chmod 755 post-commit"

A note about the hook. I have run into many problem when a hook fails to execute. Many times the problem lies in a permissions problem. Make sure that the web directory is www-data:www-data so that apache has access to execute the svn repository.

Comments

Creating a subversion hook on Dreamhost

We're using dreamhost for a project and in setting this up I've found the following information: Subversion - Dreamhost

additional information

I've been having trouble with the steps in the dreamhost wiki, but here is a link to some addition information on the topic.