Gollum is a lightweight, self-hosted wiki system that uses Git repositories as its backend, making it an ideal choice for developers and system administrators who value version control and data privacy. Designed for simplicity, Gollum allows users to create, update, and manage markdown-based wikis with full customization and control. In this guide, weβll walk through the installation, configuration, management, and advanced usage of Gollum to help you deploy a robust, self-hosted wiki.
Installing Gollum
π¦ Docker/Docker Compose Setup
Docker simplifies the deployment of Gollum by encapsulating its dependencies into a container. Hereβs how to set it up with Docker Compose:
- Create a
docker-compose.yml
file with the following content:
version: '3.8'
services:
gollum:
image: gollum/ruby:latest
container_name: gollum
ports:
- "4567:4567"
volumes:
- ./wiki:/wiki
working_dir: /wiki
command: gollum --port 4567
This configuration maps your local directory ./wiki
to the container's /wiki
directory and exposes Gollum on port 4567
.
- Deploy the container using:
docker-compose up -d
This will start Gollum in detached mode, accessible at http://<server-ip>:4567
.
- Verify the container status:
docker ps
Ensure the gollum
container is running.
π Manual Installation
If you prefer a manual setup on a Linux server, follow these steps:
- Install Ruby and build dependencies:
sudo apt update
sudo apt install -y ruby-full build-essential git
- Install the Gollum gem:
gem install gollum
- Initialize a Git repository for your wiki:
mkdir ~/wiki
cd ~/wiki
git init
- Start the Gollum server:
gollum --port 4567
Gollum will now be accessible at http://<server-ip>:4567
.
Configuring Nginx as a Reverse Proxy
π Nginx Configuration
To serve Gollum through a domain name, configure Nginx as a reverse proxy:
- Create an Nginx server block file:
sudo nano /etc/nginx/sites-available/gollum
- Add the following content:
server {
listen 80;
server_name wiki.example.com;
location / {
proxy_pass http://localhost: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_set_header X-Forwarded-Proto $scheme;
}
}
- Enable the configuration and reload Nginx:
sudo ln -s /etc/nginx/sites-available/gollum /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
π SSL/TLS Setup
Secure your Gollum instance with Let's Encrypt:
- Install Certbot:
sudo apt install -y certbot python3-certbot-nginx
- Obtain an SSL certificate:
sudo certbot --nginx -d wiki.example.com
- Verify automatic renewal:
sudo certbot renew --dry-run
Logging and Debugging Gollum
ποΈ Enabling Debug Logs
Enable debug-level logging to troubleshoot issues:
- Start Gollum with detailed logging:
gollum --verbose --port 4567
- For Docker, check logs using:
docker logs gollum
π Viewing Logs
Access logs on the filesystem or via Docker:
-
For manual installation: Logs will appear directly in the terminal where Gollum is running.
-
For Docker: Use the
docker logs
command above.
π οΈ Troubleshooting Common Issues
- Check if the Gollum server is running:
curl -I http://localhost:4567
- Validate Nginx configuration:
sudo nginx -t
- Investigate permissions on your wiki directory:
ls -ld ~/wiki
π€ Exporting Logs
Send logs to an external system like ELK Stack by forwarding Docker logs using tools like Filebeat or Fluentd.
Backup and Restore
ποΈ File-Based Backups
Since Gollum stores data in a Git repository, backup is straightforward:
- Create a tarball of the wiki directory:
tar -czvf wiki-backup.tar.gz ~/wiki
- Restore by extracting the archive:
tar -xzvf wiki-backup.tar.gz -C ~/
π Automated Backup Scripts
Set up a cron job for regular backups:
- Create a script
backup_gollum.sh
:
#!/bin/bash
tar -czvf ~/wiki-backup-$(date +%Y%m%d).tar.gz ~/wiki
- Make it executable:
chmod +x backup_gollum.sh
- Add a cron job:
crontab -e
Add the following line to run daily at midnight:
0 0 * * * /path/to/backup_gollum.sh
Updating and Upgrading Gollum
β¬οΈ Updating Docker Images
Update your Docker container to the latest version:
- Pull the latest image:
docker pull gollum/ruby:latest
- Restart the container:
docker-compose down
docker-compose up -d
π οΈ Manual Updates
For manual installations, update the Gollum gem:
gem update gollum
π Checking for Updates
Verify the installed version:
gollum --version
Compare it with the latest release on the Gollum GitHub page.
Leveraging Gollumβs Unique Features
π§ Enabling APIs
Activate Gollumβs API for programmatic access:
- Start Gollum with API support enabled:
gollum --port 4567 --allow-uploads
- Interact with the API using
curl
:
curl -X POST -F "[email protected]" http://localhost:4567/upload
π Advanced Configurations
- Enable a custom CSS file for styling:
gollum --css custom.css
- Add plugins for extended functionality:
gem install gollum-lib
Then restart Gollum to load the plugins.
Wrapping Up
Self-hosting Gollum empowers you with full control over your content while leveraging Git for versioning and collaboration. This guide provided actionable steps to install, configure, secure, and manage Gollum on your server. With its flexibility and advanced features, Gollum is an excellent choice for developers looking to build a private, customizable wiki. Start implementing the examples today to create your own powerful, self-hosted knowledge base!