divzeroweb

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

openbsd-httpd-cgit.md (3890B)


      1 ### Configuring OpenBSD httpd, slowcgi and cgit
      2 
      3 This is a guide to get [cgit](http://git.zx2c4.com/cgit/) working with the
      4 relatively new [OpenBSD httpd(8)](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/httpd.8) and
      5 [slowcgi(8)](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/slowcgi.8) in base.
      6 
      7 
      8 #### Installation
      9 
     10 Install `cgit` package:
     11 
     12 	# pkg_add cgit
     13 
     14 or build it from ports:
     15 
     16 	# cd /usr/ports/www/cgit && make && make install
     17 
     18 Enable the `httpd` and `slowcgi` services, add to `/etc/rc.conf.local`:
     19 
     20 	slowcgi_flags=
     21 	httpd_flags=
     22 
     23 
     24 #### Configuration
     25 
     26 **httpd**
     27 
     28 An example of [httpd.conf(5)](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/httpd.conf.5):
     29 
     30 	ext_ip="0.0.0.0"
     31 	server "default" {
     32 		listen on $ext_ip port 80
     33 
     34 		# serve cgit static files directly: cgit.css and cgit.png
     35 		location "/cgit.*" {
     36 			root "/cgit"
     37 			no fastcgi
     38 		}
     39 		# cgit CGI
     40 		root "/cgi-bin/cgit.cgi"
     41 		fastcgi socket "/run/slowcgi.sock"
     42 	}
     43 
     44 
     45 **slowcgi**
     46 
     47 By default the slowcgi UNIX domain socket is located at: `/var/www/run/slowcgi.sock`.
     48 For the defaults see:
     49 [slowcgi(8)](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/slowcgi.8).
     50 
     51 
     52 **cgit**
     53 
     54 The cgit binary should be located at: `/var/www/cgi-bin/cgit.cgi` (default).
     55 
     56 cgit uses the `$CGIT_CONFIG` environment variable to locate it's config. By
     57 default on OpenBSD this is set to `/conf/cgitrc` (chroot), which is
     58 `/var/www/conf/cgitrc`.
     59 
     60 An example of `cgitrc`:
     61 
     62 	footer=/conf/cgit.footer
     63 
     64 	# Enable caching of up to 1000 output entries
     65 	cache-size=1000
     66 
     67 	cache-root=/cgit/cache
     68 
     69 	# Specify some default clone urls using macro expansion
     70 	clone-url=git://git.codemadness.nl/$CGIT_REPO_URL
     71 
     72 	# Specify the css url
     73 	css=/cgit.css
     74 
     75 	# Show owner on index page
     76 	enable-index-owner=0
     77 
     78 	# Allow http transport git clone
     79 	enable-http-clone=0
     80 
     81 	# Show extra links for each repository on the index page
     82 	enable-index-links=0
     83 
     84 	# Enable ASCII art commit history graph on the log pages
     85 	enable-commit-graph=1
     86 
     87 	# Show number of affected files per commit on the log pages
     88 	enable-log-filecount=1
     89 
     90 	# Show number of added/removed lines per commit on the log pages
     91 	enable-log-linecount=1
     92 
     93 	# Sort branches by date
     94 	branch-sort=age
     95 
     96 	# Add a cgit favicon
     97 	favicon=/favicon.ico
     98 
     99 	# Enable statistics per week, month and quarter
    100 	max-stats=quarter
    101 
    102 	# Set the title and heading of the repository index page
    103 	root-title=Codemadness.org repositories
    104 
    105 	# Set a subheading for the repository index page
    106 	root-desc=
    107 
    108 	# Allow download of tar.gz, tar.bz2 and zip-files
    109 	snapshots=tar.gz
    110 
    111 	## List of common mimetypes
    112 	mimetype.gif=image/gif
    113 	mimetype.html=text/html
    114 	mimetype.jpg=image/jpeg
    115 	mimetype.jpeg=image/jpeg
    116 	mimetype.pdf=application/pdf
    117 	mimetype.png=image/png
    118 	mimetype.svg=image/svg+xml
    119 
    120 	## Search for these files in the root of the default branch of repositories
    121 	## for coming up with the about page:
    122 	readme=:README
    123 
    124 	virtual-root=/
    125 
    126 	scan-path=/htdocs/src
    127 
    128 	# Disable adhoc downloads of this repo
    129 	repo.snapshots=0
    130 
    131 	# Disable line-counts for this repo
    132 	repo.enable-log-linecount=0
    133 
    134 	# Restrict the max statistics period for this repo
    135 	repo.max-stats=month
    136 
    137 
    138 In this example the cgit cache directory is set to `/cgit/cache` (chroot),
    139 which is `/var/www/cgit/cache`. Make sure to give this directory read- and write
    140 permissions for cgit (www:www).
    141 
    142 In the example the repository `scan-path` is set to `/htdocs/src` (chroot),
    143 which is `/var/www/htdocs/src`.
    144 
    145 The footer file is set to `/conf/cgit.footer`. Make sure this file exists or you
    146 will get warnings:
    147 
    148 	# printf '' > /var/www/conf/cgit.footer
    149 
    150 Make sure `cgit.css` (stylesheet) and `cgit.png` (logo) are accessible, by default:
    151 `/var/www/cgit/cgit.css` and `/var/www/cgit/cgit.png`.
    152 
    153 
    154 #### Running the services
    155 
    156 Start the services:
    157 
    158 	# rcctl start slowcgi
    159 	# rcctl start httpd
    160 
    161 
    162 #### Have fun
    163 
    164 Written by [hiltjo](http://www.codemadness.nl/)