Faster and easier Gitweb installation

The idea of using make to build Gitweb isn’t just excessively complex, it’s also mostly unnecessary. Building gitweb.cgi from gitweb.perl only changes 19 of the source file’s 6734 lines (0.2%).

Fact is, to get Gitweb working only one line needs changing. After the following edit, all local configuration values can be loaded from a simple config file.

On line 546, insert the name of your config file:

+our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "gitweb_config.perl";

A set of fully-documented configuration files is available in the Simple Gitweb Config project on Github, to help get things up and running quickly.

Full instructions

Here are all the steps necessary to get Gitweb running on a webserver. In most cases, the configuration will work without modification, installation shouldn’t take more than five minutes start to finish.

  1. Create temporary source directory:
  2. mkdir ~/src && cd ~/src
  3. Download and extract Git source and Simple Gitweb Config tarballs:
  4. curl -LO
    curl -LO
    tar -xvzf git-1.6.6.tar.gz
    tar -xzvf master
  5. Copy Git’s gitweb subdirectory to a web accessible location, then copy the gitweb config files into the live gitweb directory:
  6. cp -r git-1.6.6/gitweb ~/www/
    cp joemaller-Simple-Gitweb-Config*/* ~/www/gitweb/
  7. Replace ++GITWEB_CONFIG++ with gitweb_config.perl and make the resulting CGI executable:
  8. sed -re's/\++GITWEB_CONFIG\++/gitweb_config.perl/g' gitweb.perl  > gitweb.cgi
    chmod a+x gitweb.cgi
  9. Gitweb should be working now, but if necessary, edit projects_list.txt, gitweb_config.perl and customize the three html files for your environment.

One last note, since it wasn’t immediately obvious to me. To change the default repository description, “Unnamed repository; edit this file to name it for gitweb.” edit the configuration file inside the .git folder. Descriptions are per-repository and do not update or transfer with pushes, pulls or clones.