divzeroweb

2f30.org website
git clone git://git.2f30.org/divzeroweb
Log | Files | Refs | README | LICENSE

commit f48c1170838a3adca8340c8079ecab96c9763254
parent 0d70f7d152f9ddbbd31342acaabb881f19dbbb12
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun,  5 Jul 2015 18:56:19 +0200

add guide to setup OpenBSD httpd with cgit

Diffstat:
MMakefile | 3++-
Mguides.md | 1+
Aguides/openbsd-httpd-cgit.md | 162+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 165 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -17,7 +17,8 @@ PAGES = $(MENUPAGES) \ guides/ipsec.html \ guides/netbsd-linode.html \ guides/rpi-tv.html \ - guides/irix-sgi-o2.html + guides/irix-sgi-o2.html \ + guides/openbsd-httpd-cgit.html EXTRA = css divzerokey.png favicon.ico index.html \ lectures/resources diff --git a/guides.md b/guides.md @@ -10,3 +10,4 @@ Just some notes on various useful tasks. * [netbsd-linode](guides/netbsd-linode.html): Installing NetBSD on Linode * [rpi-tv](guides/rpi-tv.html): Raspberry Pi console media center with TV remote on Arch Linux * [irix-sgi-o2](guides/irix-sgi-o2.html): Installing IRIX 6.5 to an SGI O2 from the network + * [openbsd-httpd-cgit](guides/openbsd-httpd-cgit.html): Configuring httpd, slowcgi and cgit on OpenBSD diff --git a/guides/openbsd-httpd-cgit.md b/guides/openbsd-httpd-cgit.md @@ -0,0 +1,162 @@ +### Configuring OpenBSD httpd, slowcgi and cgit + +This is a guide to get [cgit](http://git.zx2c4.com/cgit/) working with the +relatively new [OpenBSD httpd(8)](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/httpd.8) and +[slowcgi(8)](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/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)](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/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)](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/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: + + # /etc/rc.d/httpd start + # /etc/rc.d/slowcgi start + + +#### Have fun + +Written by [hiltjo](http://www.codemadness.nl/)