<title>How To Configure A Fossil Server</title>

<h2>No Server Required</h2>

<blockquote>
Fossil does <em>not</em> require a central server.
But, [./server/whyuseaserver.wiki|a server can be very useful].

This article is a quick-reference guide for setting up your own
Fossil server, with links to more detailed instructions specific
to particular systems, should you want extra help.
</blockquote>


<h2 id="methods">Methods</h2>

<blockquote>
There are basically four ways to set up a Fossil server:

<ol>
  <li>Socket listener:
      <a id="inetd"   href="./server/any/inetd.md">inetd</a>,
      <a id="xinetd"  href="./server/any/xinetd.md">xinetd</a>,
      <a id="stunnel" href="./server/any/stunnel.md">stunnel</a>...
  <li><a id="standalone" href="./server/any/none.md">Stand-alone HTTP server</a>
  <li><a id="scgi" href="./server/any/scgi.md">SCGI</a>
  <li><a  id="cgi" href="./server/any/cgi.md">CGI</a>
</ol>

The idea behind the socket listener approach is that each incoming HTTP
request is relayed to a new instance of the
[/help?cmd=http|fossil http] command.  That command reads the HTTP
request from its standard input, handles the request, and writes a
complete and correct HTTP reply on standard output which is then
returned to the client.

A stand-alone server uses the
[/help?cmd=server|fossil server] command to run a process that
listens for incoming HTTP requests on a socket and then dispatches
a copy of itself to deal with each incoming request.  A
stand-alone server can talk directly with the client, or the
system can be configured with a reverse proxy in between the
client and Fossil.

Fossil can also be run using CGI from ordinary web servers
such as Apache, IIS, <tt>lighttpd</tt>, or <tt>althttpd</tt>.
A [/help?cmd=cgi|short CGI script] is placed in the document
hierarchy of the web server, and when a client requests the
appropriate URL, Fossil is run to generate the responce.
CGI is a good choice for incorporating Fossil as part of a
larger website.  The Fossil [./selfhost.wiki|self-hosting repositories]
are implemented CGI running behind althttpd.

For web servers such as Nginx that do not support
CGI, Fossil can be run using SCGI.  SCGI involves running
the [/help?cmd=http|fossil http] command with the --scgi
option.  SCGI is something of a cross between a stand-alone server
running behind a reverse proxy and an ordinary CGI server.

Regardless of the method you choose, all can serve either a single
repository or a directory hierarchy containing many repositories 
with names ending in ".fossil".

Note that a single project is not restricted to using a single
server setup method.  The same Fossil repository can be served
using two or more of the above techniques, at the same time.  And
the server setup can change over time, to accomodate changes
in hosting providers or administrator preferences.
</blockquote>

<h2 id="matrix">System-Specific Setup Tutorials</h2>

<blockquote>
We've broken the configuration for each method out into a series of
sub-articles, some of which are OS-specific:
</blockquote>

<table style="margin-left: 6em;">
    <tr>
        <th>&nbsp;</th>
        <th colspan="11" style="background-color: #efefef">Fossil Front-End Program</th>
    </tr>

    <tr>
        <th style="background-color: #e8e8e8; padding: 6px; text-align: right">Host OS</th>
        <th>none</th>
        <th>inetd</th>
        <th>xinetd</th>
        <th>stunnel</th>
        <th>CGI</th>
        <th>SCGI</th>
        <th>althttpd</th>
        <th>nginx</th>
        <th>Apache</th>
        <th>IIS</th>
        <th>OS&nbsp;service</th>
    </tr>

    <tr>
        <th style="background-color: #e8e8e8; padding: 6px; text-align: right">Any</th>
        <td style="text-align: center"><a href="./server/any/none.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/inetd.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/xinetd.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/stunnel.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/cgi.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/scgi.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/althttpd.md">✅</a></td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
    </tr>

    <tr>
        <th style="background-color: #e8e8e8; padding: 6px; text-align: right">Debian/Ubuntu</th>
        <td style="text-align: center"><a href="./server/any/none.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/inetd.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/xinetd.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/stunnel.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/cgi.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/scgi.md">✅</a></td>
        <td style="text-align: center"><a href="./server/any/althttpd.md">✅</a></td>
        <td style="text-align: center"><a href="./server/debian/nginx.md">✅</a></td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
    </tr>

    <tr>
        <th style="background-color: #e8e8e8; padding: 6px; text-align: right">Windows</th>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center"><a href="./server/windows/stunnel.md">✅</a></td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center">❌</td>
        <td style="text-align: center"><a href="./server/windows/iis.md">✅</a></td>
        <td style="text-align: center"><a href="./server/windows/service.md">✅</a></td>
    </tr>
</table>

<blockquote>
Where there is a check mark in the "Any" row, the method for that is
generic enough that it works across OSes that Fossil is known to work
on. The check marks below that usually just link to this generic
documentation.

There are several widely-deployed socket listener schemes besides the
<tt>inetd</tt>, <tt>xinetd</tt>, and <tt>stunnel</tt> schemes with
documents linked above: Apple’s <tt>launchd</tt>, Linux’s
<tt>systemd</tt>, Solaris’ SMF, etc. We would welcome [./contribute.wiki
| contributions] to cover these as well. We also welcome contributions
to fill gaps (❌) in the table above.
</blockquote>


<h2 id="more">Further Details</h2>

  *  <a name="chroot"></a>[./chroot.md | The Server Chroot Jail]
  *  <a name="loadmgmt"></a>[./loadmgmt.md | Managing Server Load]
  *  <a name="tls"></a>[./ssl.wiki | Securing a Repository with TLS]
  *  <a name="ext"></a>[./serverext.wiki | CGI Server Extensions]
  *  [./aboutcgi.wiki|How CGI Works In Fossil]
  *  See "[./sync.wiki|The Fossil Sync Protocol]" for information on the
     wire protocol used for syncing Fossil repositories.
