Provide gitweb via lighttpd

How can I host gitweb via lighttpd on OpenSuSE (11.3)? I describe what I have done. [TOC]

Requirements

  • git (I used Version 1.7.1 - gitweb is available as default)
  • lighttpd rpm package according to your OS

Getting started

gitweb

provide cgi-bin directory

After git and lighttpd are installed, we have to copy our gitweb cgi-bin folder to the right position:

cp -r /usr/share/gitweb /srv/www/cgi-bin

create gitweb.conf

The gitweb config file is located at /etc/gitweb.conf

This is my gitweb config file:

# your git-binary.
$GIT = "/usr/bin/git";

# Where you have all your repos you want to host with
# gitweb.
$projectroot = "/srv/www/git-repos";

# name of your gitweb mainpage
$site_name = "My Git Repositories";
$projects_list_description_width = 90;

# standard path to style files
$stylesheet = "/gitweb.css";
$favicon = "/git-favicon.png";

# nicer-looking URLs
$feature{'pathinfo'}{'default'} = [1];

# enable blame view
$feature{'blame'}{'default'} = [1];
$feature{'blame'}{'override'} = [1];

# search is required by pickaxe and grep
$feature{'search'}{'default'} = [1];

# Enable the pickaxe search, 
# which will list the commits that modified a given 
# string in a file. This can be practical and quite faster
# alternative to 'blame'
$feature{'pickaxe'}{'default'} = [1];
$feature{'pickaxe'}{'override'} = [1];

# Enable the 'snapshot' link, providing a compressed
# archive of any tree.
$feature{'snapshot'}{'default'} = [1];
$feature{'snapshot'}{'override'} = [1];

# Enable grep search, which will list the files in
# currently selected tree containing the given string.
$feature{'grep'}{'default'} = [1];
$feature{'grep'}{'override'} = [1];

You can get the gitweb.conf file here or at GitHub.

lighttpd

enable modules

First, edit /etc/lighttpd/lighttpd.conf. We’ll need to add mod_alias and mod_cgi to the server.modules.

server.modules += (
        "mod_alias",
        "mod_cgi",
        "mod_setenv"
    )

It is also possible (if exist) to enable this modules in /etc/lighttpd/modules.conf.
Just enable mod_alias and mod_setenv at server.modules section. To enable mod_cgi insert include "conf.d/cgi.conf" into modules.conf file.

create lighttpd config

Now we can create a lighttpd-config file. I saved it at /etc/lighttpd/vhosts.d/gitweb.conf.

$HTTP["host"] =~ "^git.hostname$" {
        cgi.assign = (
            ".cgi" => "/usr/bin/perl"
        )
        alias.url += (
            "/gitweb.css"       => "/srv/www/cgi-bin/gitweb/static/gitweb.css", 
            "/gitweb-logo.png"  => "/srv/www/cgi-bin/gitweb/static/git-logo.png",
            "/"                 => "/srv/www/cgi-bin/gitweb/gitweb.cgi"
        )

        # path to gitweb config file
        setenv.add-environment = ( "GITWEB_CONFIG" => "/etc/gitweb.conf" )
    }

This file is available here or at GitHub.

load config file

To load the new config file, just type service lighttpd reload.

Now, your gitweb forntend is reachable at http://git.hostname.

comments powered by Disqus