Gollum and Passenger

cessationoftime edited this page May 16, 2012 · 5 revisions
Clone this wiki locally

How to Run Gollum Under Passenger

While Gollum is designed to be run locally we wanted to put it on a server so several of us could edit at once. This is what we did.

** NOTE ** Gollum is still very young and is being rapidly developed. There are still many ways you can trigger an internal server error (500). We're not responsible for any fallout when you decide to move your company's intranet to use Gollum!

Our System

We installed this on a system configured as below. It also worked on our Ubuntu 10.04 server with very few changes.

  • Debian 5.0.5
  • Apache 2.2.9
  • Passenger 2.2.15
  • Ruby 1.8.7
  • Gollum 1.0.1
  • Sinatra 1.0

If you want to install the latest version of the Gem this codebase represents (and get Github authentication) please see Github Authentication for Gollum.


  1. Install all your binaries listed above.
  2. Find out where your copy of Gollum got installed. Something like this command should work:
$ gem which gollum

Remove the gollum.rb bit from the end and replace with gollum/frontend/public. The example above would now look like:

  1. Decide which user you will be running Apache2 as. In Debian & Ubuntu this defaults to www-data which is what we'll use. You can find out which user it's running under on your system as follows:
$ ps auwx | grep apache
root     30874  0.0  1.8 224616  9524 ?        Ss   Aug30   0:00 /usr/sbin/apache2 -k start
www-data 30875  0.0  0.6 172132  3496 ?        S    Aug30   0:00 /usr/sbin/apache2 -k start

Ignore the root user and select the other user, in this case www-data. 4. Create an Apache virtual site file in /etc/apache2/sites-available We'll call our site 'wiki.foo.com'. Insert the path to Gollum from step 2 where indicated:

<VirtualHost *>
	ServerName wiki.foo.com
	ServerAdmin wiki-admin@foo.com
	ErrorLog /var/log/apache2/wiki.foo-error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog /var/log/apache2/wiki.foo-access.log combined
	ServerSignature On

Gollum requires modification to work with sub URIs. Follow these instructions to create a sub URI instead of creating the wiki at the documentRoot of a virtualHost. 5. Now create a symlink to your site as follows.

$ cd /etc/apache2/sites-enabled
$ ln -s ../sites-available/wiki.foo.com 015-wiki.foo.com
  1. Next install Passenger. In depth instructions can be found here but basically you ensure all dependencies are met and run passenger-install-apache2 and follow all the prompts.

make sure you create /etc/apache2/mods-available/mod-passenger.load with this line as prompted:

   LoadModule passenger_module <path/to/mod_passenger.so>

and /etc/apache2/mods-available/mod-passenger.conf with these lines as prompted:

   PassengerRoot <path/to/passenger/gem>
   PassengerRuby <path/to/ruby>
  1. Now Passenger is installed, we need to enable and configure it.
$ cd /etc/apache2/mods-enabled
$ ln -s ../mods-available/mod-passenger.conf mod-passenger.conf
$ ln -s ../mods-available/mod-passenger.load mod-passenger.load
  1. We will have permissions issues making changes to the repo unless you make sure Passenger is running as the same user as you selected in Step 3. You can do this by editing the file /etc/apache2/mods-available/mod-passenger.conf and adding the following to the end (if it's not already there):
PassengerDefaultUser www-data
  1. Next we check out our repository. Again, refer to [[Github|http://help.github.com/] for full instructions. For this demo, create your wiki repo, add a file called Readme to it, commit, push to Github and then clone into a folder on your target server. It's very important you do the clone operation as the user in step 3. This may cause some problems as you will probably need to setup a deploy key, again see [[Github|http://help.github.com/troubleshooting-ssh/] for howto's on this. For this demo, we'll be cloning it to /var/www/wiki.foo.com.
  2. We will make Gollum run under Phusion by leveraging the power of Rack and the next two steps will accomplish this. First we need to build our rackup file, config.ru which sits one folder up from the location you chose in step 2, in our case this will be /opt/ruby-1.8.7-p1/lib/ruby/gems/1.8/gems/tecnh-gollum-1.0.2.auth/lib/gollum/frontend/config.ru It looks like this (take care to make the changes where indicated):
require 'rubygems'
require 'gollum/frontend/app'

system("which git") or raise "Looks like I can't find the git CLI in your path.\nYour path is: #{ENV['PATH']}"

gollum_path = '/var/www/wiki.foo.com' # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO

disable :run

configure :development, :staging, :production do
 set :raise_errors, true
 set :show_exceptions, true
 set :dump_errors, true
 set :clean_trace, true

$path = gollum_path
Precious::App.set(:gollum_path, gollum_path)
Precious::App.set(:wiki_options, {})

run Precious::App
  1. Now all that's left to do is to set permissions and fire her up:
# Change this path to be what you selected in step 2
$ cd /opt/ruby-1.8.7-p1/lib/ruby/gems/1.8/gems/tecnh-gollum-1.0.2.auth/lib/gollum/frontend/
$ mkdir tmp
# Change www-data if you're running under another user
$ chown www-data:www-data tmp
$ chown www-data:www-data config.ru
# Restart apache
$ apache2ctl -k restart

At this point you should be all done.