Collection of themes/skins for the Fossil SCM

⌈⌋ ⎇ branch:  Fossil Skins Extra


PrefixFree

Fossil CGI setup without repo.cgi/ in the URL

You can easily setup a cgi fossil server. For a single repository, you just need a plain CGI hook:

     #!/usr/bin/fossil
     repository: /home/fossil/repo.fossil

For multiple fossils you can just as easily prepare a commonly called repo.cgi using the directory: directive instead:

     #!/usr/bin/fossil
     directory: /home/fossil/repos
     notfound: err404.html

This incures a repo.cgi/ prefix however before each repository basename in your URLs.

RewriteRule and Perl wrapper

If you already use a dedicated domain (like say http://fossil.include-once.org/) then a second virtual directory layer is redundant.

Here's where .virt comes in. It's a simple Perl CGI wrapper onto the aforementioned repo.cgi to clean up the URL path again.

  • Copy .virt alongside your repo.cgi script.

  • Setup a RewriteRule to map all basenames onto .virt instead:

         RewriteCond %{SCRIPT_FILENAME} !-f
         RewriteRule ^(\w+)(\/.*)?$  .virt   [L,QSA]
    

It'll take care of cleaning up the CGI environment, so fossil won't prefix the acual repo.cgi script before URLs.

  • It basically just sets SCRIPT_NAME to the empty string.

  • Fossil will then consume just PATH_INFO containing /reponame/page.

  • So your URLs are shortened to http://fossil.example.org/reponame/

This works on shared hosting accounts. Though you might need to name the wrapper virt.cgi instead. It's based on Perl, so incurs a minimum overhead.

Apache ScriptAlias

A much simpler option is:

 ScriptAliasMatch ^/([-_+\w]+(\/.*)?)$ /www/fossil/.repo.cgi/$1

This will pick up any filenames not containing a dot, and pass them over the .repo.cgi fossil directory handler:

#!/usr/local/bin/fossil
directory: /www/fossil.d/

As such fossil-cgi itself manages all URLs again. The Alias rewrite merely eschews the whatever.cgi/ prefix. (Fossil sees the plain REQUEST_URI/PATH_INFO, and doesn't need further overrides then.)

ScriptAliasMatch needs to be configured in a <VirtualHost> section though; not via .htaccess. Therefore it's mostly just an option on VPS/root servers, not on shared hosting.

mod_suexec CGI issues

If you're running Fossil under Apache with mod_suexec, then you might run into issues. For some reason suexec disallows the HOME environment variable to be present. A recent cool new feature of Fossil 1.30, namely TH1-hooks, however requires HOME to be correctly defined.

Declaring it requires a wrapper script to the repo.cgi handler. You can utilize Perl or env for example. More recent checkins allow to utilize a special repo.cgi setting to override HOME:

#!/usr/local/bin/fossil
HOME: /home/fslusr1/
directory: /www/fossil.d/

(Actually a fake home dir also works.)

There are a few other special CGI directives besides directory: or repository: and notfound:, btw:

  • debug: 1
  • errorlog: filename.log
  • localauth
  • redirect: http://example.org/
  • files: *.png
  • HOME: /tmp

Attachments:

  • .virt [download] added by mario on 2014-02-16 22:07:20. [details]