Version 7 (modified by ulrich@…, 11 years ago) (diff) |
---|
Getting Subversion under MacPorts
- Audience: Anyone and everyone
- Requires: MacPorts, Apache (for server installation)
Introduction
The most expedient way to get Subversion up and running on Mac OS X is to do it under MacPorts. There are a number of secondary components that Subversion depends upon and the MacPorts portfiles take care of the tedium of doing all this by hand.
These instructions assume you already have MacPorts installed and running.
Client-Only Installation
This is the easiest option. Simply type
sudo port install subversion
When MacPorts finishes, you can test out your installation by pulling down the actual Subversion project itself:
cd ~ mkdir Subversion cd Subversion svn checkout http://svn.collab.net/repos/svn/trunk trunk
Full (Client+Server) Installation
This option is is for people who want to host a Subversion server running under Apache. While MacPorts will take care of automatically downloading and installing Apache (the v2.x line), it's probably better if you get Apache configured and running first. That way, if there are problems, you can figure out whether it's with your Apache installation or with your Subversion installation. To get Apache installed, follow the Apache-specific instructions on the MAMP page. (If you know you're going to need MySQL and PHP, you might as well get those installed and out of the way too and come back to this page when you're ready.)
Step 1: Install Subversion
First run the following command for a client + server installation:
sudo port install subversion +mod_dav_svn
Step 2: Create initial repository and set up apache
Next, you will need to create a Subversion repository and tell Apache about it. Let's assume we want to set up a Subversion repository directory such that the collection of hosted repositories is accessed via http://localhost/svn/ for each repository. We're doing this so that we can host multiple repositories if we elect to do so. So, if we created two repositories, repos-1
and repos-2
, we would reference them as http://localhost/svn/repos-1 and http://localhost/svn/repos-2, respectively. Let's also assume that we want to host the repositories in a /svn
directory. There are two key things you need to do to make all this work:
- Grant ownership of the
/svn
directory to thewww
user - Establish the proper access controls in Apache's
httpd.conf
file to connect http://localhost/svn/ URLs to the/svn
directory.
First, let's set up the /svn
directory and create a repository:
cd / sudo mkdir svn cd svn sudo mkdir repos-1 sudo svnadmin create --fs-type fsfs repos-1
Next, we need to change the owner to be www
:
cd / sudo chown -R www svn
Now, we need to tell Apache to activate Subversion and how to access the repository. Go to the Apache config directory:
cd /opt/local/apache2/conf/
and edit the httpd.conf file. If you are using vi
,
sudo vi httpd.conf
and if you are using pico
,
sudo pico httpd.conf
Navigate to the "Dynamic Shared Object (DSO) Support" section (i.e., the section that has all the "LoadModule
" statements) and add the following lines at the end:
# ----- Subversion: LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
These modules are stored in /opt/local/libexec, so one has to create symbolic links in /opt/local/apache2/modules
sudo ln -s /opt/local/libexec/mod_dav_svn.so /opt/local/apache2/modules/mod_dav_svn.so sudo ln -s /opt/local/libexec/mod_authz_svn.so /opt/local/apache2/modules/mod_authz_svn.so
Alternatively, you may copy them.
Next, navigate your editor down to the very end of the file and add the following lines:
# # Define Subversion access # <Location /svn/> DAV svn SVNParentPath /svn SVNListParentPath on </Location>
Note that this is the world's simplest Subversion access configuration. It is meant only to be used to help verify that your installation is working properly. You should now be able to further configure your repository hosting according to the Subversion documentation.
Note: It is important to have the trailing slash ("/") character at the end of the directory in the
Location
directive. Older versions of Subversion didn't seem to care about the trailing slash, but versions 1.3.0 and later seem be really picky about it. It becomes an issue if you need to use an access control file to control access within the repository. So it's best to set things up correctly now, otherwise there will be great weeping and gnashing of teeth later on.
Step 3: Restart Apache and test installation
Restart Apache (sudo /opt/local/apache2/bin/apachectl -k restart
) to activate your changes.
Now, you should be ready to test your installation. First, point your browser to http://localhost/svn/ . You should see a "Collection of Repositories" page with your "repos-1" repository listed in it. It will be empty, so if you click on it, it will have nothing and be at Revision 0 (go ahead and try it!). Next, go to your home directory and create a template directory to import as your first revision:
cd ~ mkdir svn-template cd svn-template mkdir trunk branches tags
Import your template directory into the "repos-1" repository using
svn import . http://localhost/svn/repos-1 -m "Initial import."
Go back to your browser and go to http://localhost/svn/repos-1/ (if you're there already, just refresh the page). You should now see the "branches
", "tags
", and "trunk
" directories listed and the repository should be at Revision 1.
That's it. You've got a Subversion server running!