..:: AsmBB ::..: Setting up fossil on nginx web server
<img src="https://board.asm32.info/images/title.svg" alt="Title img">
<h1>AsmBB is ultrafast web forum, written entirely in assembly language. This site is the official support development forum and demo/test installation.</h1>
tag:board.asm32.info,2018-03-06:Thread1872018-03-23T08:52:01Zjohnfound on Setting up fossil on nginx web servertag:board.asm32.info,2018-03-06:Post154122018-03-23T08:52:01Z
<p>Earlier, I have wrote <a href="/how-to-install-asmbb-on-vps-with-nginx-and-systemd.163/">an article</a> explaining how to setup AsmBB forum with nginx server.
</p>
<p>But if you have nginx server up and running you can very easy host <a href="https://www.fossil-scm.org/">fossil</a> managed source code repositories.
</p>
<p>Setting up a fossil facility with nginx is very easy and trouble free. I am even wondering why this setup is not documented in details in the fossil documentation.
</p>
<p>Of course as a prerequisite you need to have fossil installed. You can do it from your Linux distro package manager, or as long as fossil is a single executable file, simply download it from the fossil web site and place it in <code>/usr/bin</code> directory.
</p>
<h2>Configuring nginx
</h2>
<p>At first, you need to choose the URL on which the fossil repositories will be located. If assume that the main web site is located on <code>http://example.com</code> one possible URL for the fossil repositories is <code>http://example.com/fossil/</code>
</p>
<p>First, you need to include in the nginx configuration file the new location. It have to be included inside the respective <code>server {}</code> section of the configuration:
</p>
<pre><code class=""># Already existing and working web server configuration
server {
.... some options ...
.... other options ...
# This is the fossil configuration you need to include
location /fossil/ {
scgi_pass 127.0.0.1:9000; # select whatever free port you want.
include scgi_params; # this file is usually
scgi_param SCRIPT_NAME "/fossil";
}
}
</code></pre>
<p>There are in general two types of nginx setup:
</p>
<p>The first is "one config file" type, where all server configuration is located in a single file, usually <code>/etc/nginx/nginx.conf</code>. In this case, you need only to look for the proper <code>server {}</code> section if there are more than one.
</p>
<p>The second type is "one config file per virtual host" where every virtual host have separate config file, usually located in some subdirectory of <code>/etc/nginx/</code> directory. In this case, you need to include the fossil configuration in one of these configuration files.
</p>
<p>Once the nginx is configured the configuration need to be reloaded with:
</p>
<pre><code class="">sudo systemctrl reload nginx
</code></pre>
<h2>Configuring fossil scgi service
</h2>
<p>Fossil can be started manually from the console (especially for tests) but it is better to create a service for systemd in order to make it start automatically on restarts and possible program faults.
</p>
<p>Create file <code>/etc/systemd/system/fossil.service</code> with the following content:
</p>
<pre><code class="">[Unit]
Description=Fossil scm SCGI script.
After=nginx.service
[Service]
Type=simple
User=YOUR_PREFERED_USER
WorkingDirectory=/DOCUMENT_ROOT/fossil
ExecStart=/usr/bin/fossil server /DOCUMENT_ROOT/fossil/ --scgi --localhost --port 9000 --repolist
Restart=on-failure
[Install]
WantedBy=nginx.service
</code></pre>
<p>Creating this file you need to replace the following placeholders:
</p>
<p><code>YOUR_PREFERED_USER</code> is the user you want run fossil script. Notice that this user must have writing access to all repository files. Otherwise fossil will not be able to manage the repositories.
</p>
<p><code>DOCUMENT_ROOT</code> is the directory where your web site is located.
</p>
<p>Now enable and start your new fossil service:
</p>
<pre><code class="">sudo systemctl enable fossil
sudo systemctl start fossil
</code></pre>
<h2>Operation
</h2>
<p>From this moment, every repository file <code>REPO_NAME.fossil</code> located in <code>/DOCUMENT_ROOT/fossil</code> directory will be served by fossil on a URL: <code>http://example.com/fossil/REPO_NAME</code>. (Notice the omitted <code>.fossil</code> extension!)
</p>
<p>On an URL <code>http://example.com/fossil/</code> fossil returns a list with links to all served repositories.
</p>
<p>Enjoy!</p>
johnfound