running gitorious on freebsd


Gitorious has some documentation on a local install for Ubuntu, RHEL, and Debian, which turned out to be slightly outdated. Now that they have leveraged the Bundler GEM manager, the installation process is much simpler.

FreeBSD is by far my platform of choice when it comes to flexible and complex open source applications, and it was a cinch to reuse the Linux documentation. Aside from having to re-write the init scripts, the entire process was very easy, and I got to try out a few different web servers for the heck of it.

I used the Ports collection to install a few necessary packages like the web server(s), a MySQL database, Ruby 1.8 and the sphinx search engine.

A few things though. I decided to use a separate server for the database, and I had originally intended to run two rails app servers, and then put nginx to act as a load-balancer between the two.

The Gitorious app itself didn’t play well with this concept, so I instead settled on a nginx and mod_passenger configuration. Nginx is great, very light-weight, and seemed to fit this task perfectly.

The necessary components that are required, and not handled by the Bundler GEM manager, are as followed:

  • Ruby ( I used 1.8, though I’d like to try 1.9 as well)
  • Git
  • A web server (Apache, Thin, Nginx…) - I used Nginx
  • A Database, and as much as I love PostgreSQL, Gitorious seems very well tested with MySQL. So, MySQL it is
  • Active MQ
  • Stomp Server
  • Sphinx Search Engine

You can run this, just be sure to configure Nginx with the PASSENGER_MODULE option, and configure mod_passenger with Nginx (and not Apache) if you choose that as your web server:

$ portinstall www/nginx databases/mysql55-server www/rubygem-mod_passenger \
              devel/git net/activemq textproc/sphinxsearch sysutils/rubygem-bundler \
              databases/ruby-mysql databases/rubygem-sqlite3

There wasn’t a port for rubygem-stompserver, so I created on and submitted a PR and supplied a patch for the port. Once that is in the tree, it has rubygem-hoe and rubygem-daemons as a REQURIED port, so those two will automatically get installed.

After that though, I was able to run the last portinstall command:

$ portinstall net/rubygem-stompserver

With the dependencies for gitorious out of the way, now we need to create a user to manage everything. Gitorious needs to run a few of its own processes, so the user cannot be a “system” account (i.e. interactive with a shell). It also needs to manage the git repositories and ssh keys.

$ pw useradd gitorious -u 211  -s /bin/bash -c 'gitorious user' -w random -s /data/www/git-www-01/apps/gitorious
Password for 'git' is: **********

Since I’ll only be su-ing to the git user, I don’t care to know the password, and I’ll probably invalidate the password hash later on.

I’ve set the git users home directory to /data/www/, and this is my level of organization when it comes to hosting web sites and their applications. A lot of examples will use /var/www, but to be honest, that has always bothered me a bit. /var is for variable data, data that is ever changing and most of the time, I just don’t care about separating the useful data from the standard system noise. So, I try to never use /var for “real” data.

I also created the git repository directory, and both active_cache and temp_cache directories under the /data dir:

    $ mkdir -p /data/gitorious_app/{active_work,tmp_work,git}

And set git as the owner. This allows the $GITORIOUS_APP/script/git-poller process to create a new git repository when someone creates a project through the webs interface.

The Gitorious repository is on, and you can clone it like so:

    $ su - gitorious
    ~> cd git-www-01/apps
    /data/www/git-www-01/apps> git clone git:// gitorious

Once you check out the gitorious repository, you will need to configure the database, and, the gitorious server itself.

Link gitorious to /usr/bin:

    ln -s /data/www/git-www-01/apps/gitorious/script/gitorious /usr/bin

as root, install gems via bundle

    # bundle install