openbsd-httpd-and-cgit.md - www.codemadness.org - www.codemadness.org saait content files
 (HTM) git clone git://git.codemadness.org/www.codemadness.org
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       openbsd-httpd-and-cgit.md (2001B)
       ---
            1 This is a guide to get [cgit](https://git.zx2c4.com/cgit/) working with
            2 [OpenBSD httpd(8)](https://man.openbsd.org/httpd.8) and
            3 [slowcgi(8)](https://man.openbsd.org/slowcgi.8) in base.  OpenBSD httpd is very simple to setup, but nevertheless
            4 this guide might help someone out there.
            5 
            6 
            7 ## Installation
            8 
            9 Install the cgit package:
           10 
           11         # pkg_add cgit
           12 
           13 or build it from ports:
           14 
           15         # cd /usr/ports/www/cgit && make && make install
           16 
           17 
           18 ## Configuration
           19 
           20 ### httpd
           21 
           22 An example of [httpd.conf(5)](https://man.openbsd.org/httpd.conf.5):
           23 [httpd.conf](downloads/openbsd-httpd/httpd.conf).
           24 
           25 
           26 ### slowcgi
           27 
           28 By default the slowcgi UNIX domain socket is located at:
           29 /var/www/run/slowcgi.sock.  For this example we use the defaults.
           30 
           31 
           32 ### cgit
           33 
           34 The cgit binary should be located at: /var/www/cgi-bin/cgit.cgi (default).
           35 
           36 cgit uses the $CGIT_CONFIG environment variable to locate its config.  By
           37 default on OpenBSD this is set to /conf/cgitrc (chroot), which is
           38 /var/www/conf/cgitrc.  An example of the cgitrc file is here: [cgitrc](downloads/openbsd-httpd/cgitrc).
           39 
           40 In this example the cgit cache directory is set to /cgit/cache (chroot), which
           41 is /var/www/cgit/cache.  Make sure to give this path read and write permissions
           42 for cgit (www:daemon).
           43 
           44 In the example the repository path (scan-path) is set to /htdocs/src (chroot),
           45 which is /var/www/htdocs/src.
           46 
           47 The footer file is set to /conf/cgit.footer. Make sure this file exists or you
           48 will get warnings:
           49 
           50         # >/var/www/conf/cgit.footer
           51 
           52 Make sure cgit.css (stylesheet) and cgit.png (logo) are accessible, by default:
           53 /var/www/cgit/cgit.{css,png} (location can be changed in httpd.conf).
           54 
           55 To support .tar.gz snapshots a static gzip binary is required in the chroot
           56 /bin directory:
           57 
           58         cd /usr/src/usr.bin/compress
           59         make clean && make LDFLAGS="-static -pie"
           60         cp obj/compress /var/www/bin/gzip
           61 
           62 
           63 ## Running the services
           64 
           65 Enable the httpd and slowcgi services to automatically start them at boot:
           66 
           67         # rcctl enable httpd slowcgi
           68 
           69 Start the services:
           70 
           71         # rcctl start httpd slowcgi