Configuring Gitweb on Ubuntu
I've been digging into Git more lately as a revision control system for my personal stuff, and wanted a nice GUI way to visualize diffs in a browser. Enter Gitweb. I poked around and found bits and pieces of tutorials, but nothing specific for Ubuntu. So I present to you my step-by-step on how I got it working viewing repos.
Ensure you have a working Apache setup first.
Install the package: aptitude install gitweb
Edit your /etc/gitweb.conf. The most important setting in there is $projectroot, which is the parent directory of the Git repos you want to share.
Since I am not using a specific name-based virtual host for this, I just added the gitweb directory setup to the base Apache config. Since Ubuntu includes the entire /etc/apache2/conf.d dir, I just stuck the below in /etc/apache2/conf.d/gitweb:
:::bash RewriteEngine on RewriteRule ^/gitweb/([a-zA-Z0-9_-]+.git)/?(?.*)?$ /cgi-bin/gitweb.cgi/$1 [L,PT]
Alias /gitweb /scratch Options Indexes FollowSymlinks ExecCGI DirectoryIndex /cgi-bin/gitweb.cgi AllowOverride None
/scratch, used above, is the parent directory of my Git repositories.
- The only gotcha I found in the installation, is that the gitweb.cgi by default expects its media related files, CSS, gifs, etc in the root directory of the URL. For simplicities sake, I just copied these files, found in /usr/share/gitweb to /var/www. If you wish to change this, like most people will, just edit your gitweb.conf, which is found under /etc, and change the path to a place you expect the files to live.
Hopefully this helps someone else setting up Gitweb. I am sure there are some security enhancements I could make surrounding Gitweb, but since this is a simple home installation, I did not go down that route.