OpenBSD httpd, slowcgi and cgit

Last modification on

This is a guide to get cgit working with 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 the cgit package:

# pkg_add cgit

or build it from ports:

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

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 its config. By default on OpenBSD this is set to /conf/cgitrc (chroot), which is /var/www/conf/cgitrc. An example of the cgitrc file 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