PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1
CHAPTER 17 ■ VERSION CONTROL WITH SUBVERSION

Configuring a Subversion Repository


Whether you are running Subversion locally or across multiple clients, you must have a repository in
place before you can start work. What’s more, every user’s Subversion client must know where that
repository is. In this section, I look at the steps necessary to get Subversion up and running, either on a
single machine or over the Internet. I assume root access to a Linux machine. In order to create and
manage a repository you need the svnadmin command.


Creating a Repository


You can create a Subversion repository with a simple svnadmin subcommand: create. This will create a
properly configured Subversion repository directory.
Here, I create a repository in the directory /var/local/svn. Generally speaking, only the root user
can create and modify directories in /var/local, so I run the following command as root:


$ svnadmin create --fs-type fsfs /var/local/svn


This command will execute silently, but you should find that it has created a directory called svn in
the /var/local directory. The fs-type flag is not strictly necessary here, because fsfs is the default
setting. This directive orders Subversion to use files to store version information. The alternative bdb
specifies Berkeley DB to manage this data.
Let’s assume that you have multiple users on this Linux machine, all of whom will need to commit
to and update from this repository. You need to ensure that they can all write to the /var/local/svn
directory. You can do this by adding these users to a common group and making the directory writable
by this group.
You can create a new group (called svnusers) on the command line like this:


$ groupadd svnusers


You must run the groupadd command as root. You should now have this group on your system.
First, I'll add a user, bob, on the current host to the svnusers group. You can track this by monitoring
a special file called /etc/group. In /etc/group, you should find a line that looks like this:


$ svnusers:x:504:


I add bob to the group with this command:

$ usermod -aG svnusers bob


Now, if you look at /etc/group, you should see that bob has been associated with the svnusers group.

$ svnusers:x:504:bob,


Next, I need to ensure that /var/local/svn is writable by anyone in the svnusers group. I can do this
by changing the group of /var/local/svn to svnusers.


$ chgrp -R svnusers /var/local/svn/
$ chmod -R g+rws /var/local/svn/

Free download pdf