OpenBSD httpd, slowcgi and cgit

Last modification on 2015-07-05


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.


Install the cgit package:

# pkg_add cgit

or build it from ports:

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



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


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


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:

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

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

To support .tar.gz snapshots a static gzip binary is required in the chroot /bin directory:

cd /usr/src/usr.bin/compress
make clean && make LDFLAGS="-static -pie"
cp obj/compress /var/www/bin/gzip

Running the services

Enable the httpd and slowcgi services to automatically start them at boot:

# rcctl enable httpd slowcgi

Start the services:

# rcctl start httpd slowcgi