ctx->guides->openbsd-httpd-cgit
Configuring OpenBSD httpd, slowcgi and cgit
This is a guide to get cgit working with the relatively new OpenBSD httpd(8) and slowcgi(8) in base.
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):
ext_ip="0.0.0.0"
server "default" {
listen on $ext_ip port 80
# serve cgit static files directly: cgit.css and cgit.png
location "/cgit.*" {
root "/cgit"
no fastcgi
}
# cgit CGI
root "/cgi-bin/cgit.cgi"
fastcgi socket "/run/slowcgi.sock"
}
slowcgi
By default the slowcgi UNIX domain socket is located at: /var/www/run/slowcgi.sock
.
For the defaults see:
slowcgi(8).
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
:
footer=/conf/cgit.footer
# Enable caching of up to 1000 output entries
cache-size=1000
cache-root=/cgit/cache
# Specify some default clone urls using macro expansion
clone-url=git://git.codemadness.nl/$CGIT_REPO_URL
# Specify the css url
css=/cgit.css
# Show owner on index page
enable-index-owner=0
# Allow http transport git clone
enable-http-clone=0
# Show extra links for each repository on the index page
enable-index-links=0
# Enable ASCII art commit history graph on the log pages
enable-commit-graph=1
# Show number of affected files per commit on the log pages
enable-log-filecount=1
# Show number of added/removed lines per commit on the log pages
enable-log-linecount=1
# Sort branches by date
branch-sort=age
# Add a cgit favicon
favicon=/favicon.ico
# Enable statistics per week, month and quarter
max-stats=quarter
# Set the title and heading of the repository index page
root-title=Codemadness.org repositories
# Set a subheading for the repository index page
root-desc=
# Allow download of tar.gz, tar.bz2 and zip-files
snapshots=tar.gz
## List of common mimetypes
mimetype.gif=image/gif
mimetype.html=text/html
mimetype.jpg=image/jpeg
mimetype.jpeg=image/jpeg
mimetype.pdf=application/pdf
mimetype.png=image/png
mimetype.svg=image/svg+xml
## Search for these files in the root of the default branch of repositories
## for coming up with the about page:
readme=:README
virtual-root=/
scan-path=/htdocs/src
# Disable adhoc downloads of this repo
repo.snapshots=0
# Disable line-counts for this repo
repo.enable-log-linecount=0
# Restrict the max statistics period for this repo
repo.max-stats=month
In this example the cgit cache directory is set to /cgit/cache
(chroot),
which is /var/www/cgit/cache
. Make sure to give this directory read- and write
permissions for cgit (www:www).
In the example the repository 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 accessible, by default:
/var/www/cgit/cgit.css
and /var/www/cgit/cgit.png
.
Running the services
Start the services:
# rcctl start slowcgi
# rcctl start httpd
Have fun
Written by hiltjo