Subversion for BSD With All the Bells and Whistlesby Jeff Palmer
I recently took a position with a new employer. One of the first tasks they had was to set up a full Subversion server with all the bells and whistles. My subversion experience was a bit limited, so the task seemed daunting. Luckily, I ran across an OnLamp article written by Dru Lavigne that helped get me up to speed relatively quickly. Because my employer wanted all the bells and whistles, the article only covered the basics of what I needed done.
My employer has several projects in Subversion. Some are closed source, others are open source. Subversion is a revision control system, that allows groups of people to collaborate on a project without overwriting another persons work/effort. Additionally, authentication was to be encrypted, and we needed Trac set up for each project. Trac is a web-based trouble ticket and repository viewer, among other things. It's rather useful for tracking bugs, feature/enhancement requests, and other similar aspects. It is exceptionally handy for collaborative efforts as well.
To add to the complexity, Trac was to run via Apache-2.2.x using mod_python and have a postgreSQL database backend. Lastly, I had some requirements of my own. I wanted to make sure each piece of software was in the FreeBSD ports tree, for easy administration. Also, this company does a lot of communication via IRC (Internet Relay Chat), so I wanted to setup a method to have announcements sent to the developers on the channel. As you can see, the number of requirements was quickly building, and there didn't seem to be an abundance of FreeBSD-related documentation.
Since I already knew I was going to be using Apache and mod_python for Trac, I decided to use mod_dav_SVN and have Apache handle everything including authentication to SVN. I proceeded to install Apache.
# cd /usr/ports/www/apache22 # make WITH_BERKELEYDB=db42 WITH_MPM=worker install
Subversion will use Berkeley DB as its backend, so we compile Apache with support. Through trial and error, I found that after a period of time "prefork MPM" left several unresponsive httpds running, and eventually, Apache would stop answering requests. "Worker MPM" seems to have fixed the problem rather nicely.
Next, we move on to installing Subversion itself.
# cd /usr/ports/devel/subversion # make WITH_PYTHON=yes WITH_MOD_DAV_SVN=yes WITH_APACHE2_APR=yes install
We want Subversion to have python bindings for Trac. The other two options are to compile the DAV module and use Apache's APR, instead of the standalone.
Of course, the Apache installation isn't complete without mod_python!
# cd /usr/ports/www/mod_python3 # make all install clean
We don't need any extra WITH_* targets, just let it compile and install.
Next, we'll get postgreSQL setup. I only needed the client installed, because we run a central database server. You may want to run postgreSQL server on the same machine.
# cd /usr/ports/databases/postgresql82-server/ # make install /* Select the libc_r option in the menu
# cd /usr/ports/databases/postgresql82-client # make install /* Select the libc_r option in the options menu */
libc_r is used by plpython, and is desirable for Trac.
And finally, we need to install Trac.
# cd /usr/ports/www/trac # make install /* Select PGSQL support in the options menu */
Now that we have the software installed, we'll need to configure it.
Because each of the ports modified the Apache config, we'll need to change some things.
Using your favorite editor, open /usr/local/etc/apache22/httpd.conf
Remove the line:
LoadModule dav_module libexec/apache22/mod_dav.so
(The way we installed it, made 2 identical entries. Remove one.)
LoadModule python_module libexec/apache22/mod_python.so
to enable the python module for Trac.
We'll need to set apache to start on system boot.
Edit /etc/rc.conf. Add:
If you installed postgreSQL server, we'll also want that to start.
Edit /etc/rc.conf. Add:
You'll also need to run a couple commands to initialize and start the postgreSQL database.
# sh /usr/local/etc/rc.d/postgresql initdb # sh /usr/local/etc/rc.d/postgresql start
First, we'll need to create the Subversion repository and set up the Trac environment.
# svanadmin create /home/svn/projectname # trac-admin /home/trac/projectname initenv
svnadmin command initializes the Subversion repository, and gets it ready to store all of the code for your new project.
trac-admin will initialize the Trac environment, and make it accessible through the web browser. Make sure to create your PostgreSQL database prior to this step. Also, both subdirectories are owned by the wrong user:group. To fix this, we'll issue the following command:
# chown -R www:www /home/svn/projectname # chown -R www:www /home/trac/projectname
This will allow the Apache process to make changes to those directories.
We'll also need to assign administrative permissions to the Trac environment. The easiest way to do this is with a plugin.
# cd /usr/ports/www/trac-webadmin # make all install clean
You'll also need to assign yourself
trac_admin privileges to use the plugin. After you run the following command, log out and back in again. You should see a new "Admin" tab on your Trac navigation menu.
# trac-admin /home/trac/projectname permission add yourusername TRAC-ADMIN
Next, we'll setup Apache and Trac to handle a common installation scenario. This would be suitable for an open source project where anyone is allowed to check out the repository, and create trouble tickets in Trac, while the write functions of SVN, and logging into trac are done over SSL.
Pages: 1, 2