openbsd-httpd-and-cgit.html - 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.html (4192B)
---
1 <!DOCTYPE html>
2 <html dir="ltr" lang="en">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5 <meta http-equiv="Content-Language" content="en" />
6 <meta name="viewport" content="width=device-width" />
7 <meta name="keywords" content="OpenBSD httpd, slowcgi, cgit, FastCGI" />
8 <meta name="description" content="OpenBSD httpd, slowcgi and cgit" />
9 <meta name="author" content="Hiltjo" />
10 <meta name="generator" content="Static content generated using saait: https://codemadness.org/saait.html" />
11 <title>OpenBSD httpd, slowcgi and cgit - Codemadness</title>
12 <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
13 <link rel="stylesheet" href="print.css" type="text/css" media="print" />
14 <link rel="alternate" href="atom.xml" type="application/atom+xml" title="Codemadness Atom Feed" />
15 <link rel="alternate" href="atom_content.xml" type="application/atom+xml" title="Codemadness Atom Feed with content" />
16 <link rel="icon" href="/favicon.png" type="image/png" />
17 </head>
18 <body>
19 <nav id="menuwrap">
20 <table id="menu" width="100%" border="0">
21 <tr>
22 <td id="links" align="left">
23 <a href="index.html">Blog</a> |
24 <a href="/git/" title="Git repository with some of my projects">Git</a> |
25 <a href="/releases/">Releases</a> |
26 <a href="gopher://codemadness.org">Gopherhole</a>
27 </td>
28 <td id="links-contact" align="right">
29 <span class="hidden"> | </span>
30 <a href="feeds.html">Feeds</a> |
31 <a href="pgp.asc">PGP</a> |
32 <a href="mailto:hiltjo@AT@codemadness.DOT.org">Mail</a>
33 </td>
34 </tr>
35 </table>
36 </nav>
37 <hr class="hidden" />
38 <main id="mainwrap">
39 <div id="main">
40 <article>
41 <header>
42 <h1>OpenBSD httpd, slowcgi and cgit</h1>
43 <p>
44 <strong>Last modification on </strong> <time>2021-04-11</time>
45 </p>
46 </header>
47
48 <p>This is a guide to get <a href="https://git.zx2c4.com/cgit/">cgit</a> working with
49 <a href="https://man.openbsd.org/httpd.8">OpenBSD httpd(8)</a> and
50 <a href="https://man.openbsd.org/slowcgi.8">slowcgi(8)</a> in base. OpenBSD httpd is very simple to setup, but nevertheless
51 this guide might help someone out there.</p>
52 <h2>Installation</h2>
53 <p>Install the cgit package:</p>
54 <pre><code># pkg_add cgit
55 </code></pre>
56 <p>or build it from ports:</p>
57 <pre><code># cd /usr/ports/www/cgit && make && make install
58 </code></pre>
59 <h2>Configuration</h2>
60 <h3>httpd</h3>
61 <p>An example of <a href="https://man.openbsd.org/httpd.conf.5">httpd.conf(5)</a>:
62 <a href="downloads/openbsd-httpd/httpd.conf">httpd.conf</a>.</p>
63 <h3>slowcgi</h3>
64 <p>By default the slowcgi UNIX domain socket is located at:
65 /var/www/run/slowcgi.sock. For this example we use the defaults.</p>
66 <h3>cgit</h3>
67 <p>The cgit binary should be located at: /var/www/cgi-bin/cgit.cgi (default).</p>
68 <p>cgit uses the $CGIT_CONFIG environment variable to locate its config. By
69 default on OpenBSD this is set to /conf/cgitrc (chroot), which is
70 /var/www/conf/cgitrc. An example of the cgitrc file is here: <a href="downloads/openbsd-httpd/cgitrc">cgitrc</a>.</p>
71 <p>In this example the cgit cache directory is set to /cgit/cache (chroot), which
72 is /var/www/cgit/cache. Make sure to give this path read and write permissions
73 for cgit (www:daemon).</p>
74 <p>In the example the repository path (scan-path) is set to /htdocs/src (chroot),
75 which is /var/www/htdocs/src.</p>
76 <p>The footer file is set to /conf/cgit.footer. Make sure this file exists or you
77 will get warnings:</p>
78 <pre><code># >/var/www/conf/cgit.footer
79 </code></pre>
80 <p>Make sure cgit.css (stylesheet) and cgit.png (logo) are accessible, by default:
81 /var/www/cgit/cgit.{css,png} (location can be changed in httpd.conf).</p>
82 <p>To support .tar.gz snapshots a static gzip binary is required in the chroot
83 /bin directory:</p>
84 <pre><code>cd /usr/src/usr.bin/compress
85 make clean && make LDFLAGS="-static -pie"
86 cp obj/compress /var/www/bin/gzip
87 </code></pre>
88 <h2>Running the services</h2>
89 <p>Enable the httpd and slowcgi services to automatically start them at boot:</p>
90 <pre><code># rcctl enable httpd slowcgi
91 </code></pre>
92 <p>Start the services:</p>
93 <pre><code># rcctl start httpd slowcgi
94 </code></pre>
95
96 </article>
97 </div>
98 </main>
99 </body>
100 </html>