This guide will explain installation of Gollum Wiki on Ubuntu 18.04 LTS. Gollum is an open source simple wiki system built on top of Git. Wiki contents are stored in Git repository as text files and can be organized into directories. Gollum work with all recognized file formats including images, PDFs and headers/footers.

Gollum pages may be written in a variety of markup languages and can be edited from the built-in web interface, your text editor or IDE. There is also support for advanced functionalities like macros, UML diagrams, metadata, and more.

Install Gollum Wiki on Ubuntu 18.04

This section will discuss the steps of installing Gollum Wiki on Ubuntu 18.04. We will start by installing dependencies required, and later build and configure Gollum Wiki on Ubuntu 18.04.

Step 1: Install Gollum & Dependencies

We need all dependencies installed. Run below commands to install them.

sudo apt update
sudo apt install -y ruby ruby-dev make zlib1g-dev libicu-dev build-essential git asciidoc cmake

Gollum in written in Ruby and a number of Ruby gems are required. Let’s ensure the basic are installed.

sudo gem install gollum \
org-ruby \
omnigollum \
github-markup \
omniauth-github

All Gollum markups are rendered by the github-markup gem, but you can easily add support for other markups by additional installation. Example:

MediaWiki:

sudo gem install wikicloth

Textile:

sudo gem install RedCloth

GitHub Flavored Markdown:

sudo gem install github-markdown

Step 2: Setting up Gollum Git repository

After the initial installation, Gollum requires a git repository to be pointed at to work. Let’s first add a dedicated user to access that repository.

$ sudo adduser --shell /bin/bash --gecos 'Gollum application' gollum
Adding user gollum' ... Adding new groupgollum' (1001) …
Adding new user gollum' (1001) with groupgollum' …
Creating home directory /home/gollum' ... Copying files from/etc/skel' …
Enter new UNIX password: <Enter Password>
Retype new UNIX password: <Retype Password>
passwd: password updated successfully

Switch to gollum user and configure Git username and email address.

sudo su - gollum
git config --global user.name "John Doe"
git config --global user.email "[email protected]"

Create wiki directory and initialize it.

$ mkdir wiki && cd wiki
$ git init .
Initialized empty Git repository in /home/gollum/wiki/.git/

Step 3: Configure Gollum Systemd service

We’ll be setting up Gollum to start as a systemd service when the server starts. This will allow us to control its start/stop/restart when we need to shut it down (e.g. on upgrades).

Create Gollum configurations directory

sudo mkdir /etc/gollum/
Add configuration template.
$ cat<<EOF | sudo tee /etc/gollum/config.rb
=begin
This file can be used to (e.g.):
- alter certain inner parts of Gollum,
- extend it with your stuff.

It is especially useful for customizing supported formats/markups. For more information and examples:
- https://github.com/gollum/gollum#config-file

=end

# enter your Ruby code here ...
EOF

Create a new Gollum systemd unit file.

$ cat<<EOF | sudo tee /etc/systemd/system/gollum.service
[Unit]
Description=Gollum wiki server
After=network.target
After=syslog.target

[Service]
Type=simple
User=gollum
Group=gollum
WorkingDirectory=/home/gollum/wiki/
ExecStart=/usr/local/bin/gollum --live-preview --config "/etc/gollum/config.rb"
Restart=on-abort

[Install]
WantedBy=multi-user.target
EOF

Reload systemd configuration

sudo systemctl daemon-reload

Start and enable the service to start at boot.

sudo systemctl start gollum.service
sudo systemctl enable gollum.service

Check service status, it should show running.

$ systemctl status gollum
gollum.service - Gollum wiki server
Loaded: loaded (/etc/systemd/system/gollum.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-03-16 10:08:45 PDT; 9s ago
Main PID: 4527 (gollum)
Tasks: 2 (limit: 1110)
CGroup: /system.slice/gollum.service
`-4527 /usr/bin/ruby2.5 /usr/local/bin/gollum --live-preview --config /etc/gollum/config.rb
Mar 16 10:08:45 ubuntu-01 systemd[1]: Started Gollum wiki server.
Mar 16 10:08:46 ubuntu-01 gollum[4527]: [2019-03-16 10:08:46] INFO WEBrick 1.4.2
Mar 16 10:08:46 ubuntu-01 gollum[4527]: [2019-03-16 10:08:46] INFO ruby 2.5.1 (2018-03-29) [x86_64-linux-gnu]
Mar 16 10:08:46 ubuntu-01 gollum[4527]: == Sinatra (v1.4.8) has taken the stage on 4567 for development with backup from WEBrick
Mar 16 10:08:46 ubuntu-01 gollum[4527]: [2019-03-16 10:08:46] INFO WEBrick::HTTPServer#start: pid=4527 port=4567

Gollum runs on TCP port

$ ss -tunelp | grep 4567
tcp LISTEN 0 128 0.0.0.0:4567 0.0.0.0:* users:(("gollum",pid=4527,fd=7)) uid:1001 ino:63478 sk:5 <->

Web dashboard can be accessed on Server IP address and port 4567.

Step 4: Configure Nginx proxy

The default setting is to expose Gollum web console on server IP address. If you want to access it via domain name, you’ll need to configure Nginx.

Install nginx web server on Ubuntu 18.04

sudo apt -y install nginx

Once installed, add nginx configuration.

sudo vim /etc/nginx/conf.d/gollum.conf

Modify below data and add it to the file.

server {
    listen 80;
    server_name wiki.example.com www.wiki.example.com;

    location / {
        proxy_pass              http://127.0.0.1:4567;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_connect_timeout   150;
        proxy_send_timeout      100;
        proxy_read_timeout      100;
        proxy_buffers           4 32k;
        client_max_body_size    500m;
        client_body_buffer_size 128k;
    }
    access_log  /var/log/nginx/gollum-access.log;
    error_log   /var/log/nginx/gollum-error.log;

}

Replace wiki.example.com with your domain name and validate Nginx configurations.

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart nginx to load new configuration file.

sudo systemctl restart nginx

For SSL configuration. refer to configuration file below.

server {
    listen 443 ssl http2;
    server_name wiki.example.com www.wiki.example.com;

    location / {
        proxy_pass              http://127.0.0.1:4567;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_connect_timeout   150;
        proxy_send_timeout      100;
        proxy_read_timeout      100;
        proxy_buffers           4 32k;
        client_max_body_size    500m;
        client_body_buffer_size 128k;
    }

    ssl on;
    ssl_certificate /etc/letsencrypt/live/wiki.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/wiki.example.com/privkey.pem; 

    ssl_session_timeout 5m;
    ssl_ciphers  EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_protocols TLSv1.2;
    ssl_prefer_server_ciphers on;

    access_log  /var/log/nginx/gollum-access.log;
    error_log   /var/log/nginx/gollum-error.log;

}

server {
    listen      80;
    server_name wiki.example.com;

    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^ https://$server_name$request_uri? permanent;
}

Where:

  • wiki.example.com is your domain name for Wiki
  • /etc/letsencrypt/live/wiki.example.com/fullchain.pem is a path to your SSL certificate.
  • /etc/letsencrypt/live/wiki.example.com/privkey.pem is the path to SSL private key.
  • The above configurationn will redirect all http traffic to https.

Our next guide will cover how to configure Authentication for Gollum Wiki pages.

Other Wiki installation guides:

How to Install Wiki.js on Ubuntu 18.04 / CentOS 7

How to Install DokuWiki on Ubuntu 18.04 with Nginx and Letsencrypt

Install Dokuwiki with Nginx and Letsencrypt SSL on CentOS 7