OpenBSD httpd, slowcgi and cgit

Written: 2015-07-05

Description

This is a guide to get cgit working with the relatively new OpenBSD httpd(8) and slowcgi(8) in base. OpenBSD httpd is very simple to setup, but nevertheless this guide might help someone out there.

Installation

Install cgit package:

# pkg_add cgit

or build it from ports:

# cd /usr/ports/www/cgit && make && make install

Enable the httpd and slowcgi services, add to /etc/rc.conf.local:

slowcgi_flags=
httpd_flags=

Configuration

httpd

An example of httpd.conf(5): httpd.conf.

slowcgi

By default the slowcgi UNIX domain socket is located at: /var/www/run/slowcgi.sock. For this example we use the defaults.

cgit

The cgit binary should be located at: /var/www/cgi-bin/cgit.cgi (default).

cgit uses the $CGIT_CONFIG environment variable to locate it's config. By default on OpenBSD this is set to /conf/cgitrc (chroot), which is /var/www/conf/cgitrc. An example of cgitrc is here: cgitrc.

In this example the cgit cache directory is set to /cgit/cache (chroot), which is /var/www/cgit/cache. Make sure to give this path read and write permissions for cgit (www:daemon).

In the example the repository path (scan-path) is set to /htdocs/src (chroot), which is /var/www/htdocs/src.

The footer file is set to /conf/cgit.footer. Make sure this file exists or you will get warnings:

# printf '' > /var/www/conf/cgit.footer

Make sure cgit.css (stylesheet) and cgit.png (logo) are accesible, by default: /var/www/cgit/cgit.{css,png} (location can be changed in httpd.conf).

Running the services

Start the services:

# /etc/rc.d/httpd start
# /etc/rc.d/slowcgi start