There are many blog posts and howtos about setting up gitweb on the web. Unfortunately none of those seems to work for me. Either you can’t check out via http or it’s just not working.
Here is my configuration, which works for me on Debian Lenny. If you follow this instructions you’ll get a working gitweb Webinterface, checkouts via HTTP and git URLs.
First create a new directory to hold the git repositories. I’ll use the FHS compliant /srv/git:
mkdir /srv/git |
Then create a new Apache 2 Vhost:
<virtualhost *:80> ServerName git.example.net ServerAdmin you@example.net SetEnv GITWEB_CONFIG /etc/gitweb.conf DocumentRoot /srv/git ErrorLog /var/log/apache2/git.example.net-error.log CustomLog /var/log/apache2/git.example.net-access.log combined HostnameLookups On UseCanonicalName Off ServerSignature Off Alias /gitweb.css /usr/share/gitweb/gitweb.css Alias /git-favicon.png /usr/share/gitweb/git-favicon.png Alias /git-logo.png /usr/share/gitweb/git-logo.png Alias /git /srv/git ScriptAlias /gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi DirectoryIndex gitweb.cgi <directory /srv/git> AllowOverride None Options Indexes FollowSymlinks Order Allow,Deny Allow From All RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.* /gitweb.cgi/$0 [L,PT] </directory> # for debugging rewrite rules #RewriteLog /srv/www/git.gauner.org/logs/rewrite.log #RewriteLogLevel 9 </virtualhost> |
In most tutorials you’re told to include the RewriteCond matching directories (!-d), but for me that broke pretty URLs, so I disabled it.
If you use lighttpd, check out this FAQ entry.
Now you’ll need to make some adjustments to /etc/gitweb.conf:
$projectroot = "/srv/git"; # turn off potentially CPI-intensive features $feature{'search'}{'default'} = [undef]; $feature{'blame'}{'default'} = [undef]; $feature{'pickaxe'}{'default'} = [undef]; $feature{'grep'}{'default'} = [undef]; $feature{'snapshot'}{'default'} = [undef]; # nicer-looking URLs (req. apache rewrite rules) $feature{'pathinfo'}{'default'} = [1]; $site_name = "git.example.net"; $my_uri = "http://git.example.net"; # target of the home link on top of all pages $home_link = $my_uri || "/"; @git_base_url_list = ("git://git.example.net"); |
Restart the Apache and checkout if your Vhost works.
Finally you can setup the OpenBSD inetd in /etc/inetd.conf add this line:
git stream tcp nowait nobody /usr/bin/git-daemon git-daemon --inetd --verbose --base-path=/srv/git /srv/git |
Now you’re done. Of course you need to install apache2, gitweb and openbsd-inetd but that should be clear
Go here or here for more information.

Thanks for referencing me! I appreciate the pingback =)
Cheers,
Ben
Thanks a lot for your great howto! I’ve tried to follow many other posts concerning gitweb/apache2 configuration on Debian
but none of them really worked for me. Until I’ve found this one
Cheers,
Sylwester
Nice, clear, and concise!
Just setup a git repo on openipcam.com for my ipcamera work – yours was the fastest solution..
Lawrence.
Hi,
I’ve tried your tutorial, but I still have a problem with cloning git repository to other PC running on Win7.
So the current configuration is GIT server, Linux Mint 12, installed apache2, git-core, gitweb and telnetd (for inetd configuration).
Server side is configured as everything as you stated. And if I look at git.staleksit.com (this is my server name instead od example.net as your tutorial states).
Git version on server: 1.7.8.1
On client side I have Win7, git version 1.7.8.msysgit.0. Using GIT GUI.
If I open browser: http://git.staleksit.com I am getting list of projects (hello is my first project)
But If I try to clone this project on my Win7 machine I am getting: The requested URL returned error: 400 while accessing info/refs.
Can you please help me with this ???
s/CPI/CPU/