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.
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.
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.