From subversion to git (part2 – gitweb)
Assuming you have installed the Debian gitweb package
sudo apt-get install gitweb
you will find the gitweb configuration under “/etc/gitweb.conf”. Let’s configure it to point to the previously created git repository and disable some of the expensive features.
$my_uri = "http://yourserver.com/gitweb"; $site_name = "yourserver.com/gitweb"; $projectroot = "/home/git/repositories"; $git_temp = "/tmp"; $home_link = $my_uri; $home_text = "indextext.html"; $projects_list = $projectroot; $stylesheet = "/gitweb/gitweb.css"; $logo = "/gitweb/git-logo.png"; $favicon = "/gitweb/git-favicon.png"; $projects_list_description_width = 40; $feature{'pathinfo'}{'default'} = [1]; $feature{'search'}{'default'} = [undef]; $feature{'blame'}{'default'} = [undef]; $feature{'pickaxe'}{'default'} = [undef]; $feature{'grep'}{'default'} = [undef];
The package installs the actual CGI under “/usr/lib/cgi-bin/gitweb.cgi”. So make sure your httpd config includes the proper script alias
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
and include the following segment into your virtual host configuration.
RewriteEngine on RewriteRule ^/gitweb/([a-zA-Z0-9_\-]+\.git)/?(\?.*)?$ /cgi-bin/gitweb.cgi/$1 [L,PT] Alias /gitweb /home/git/gitweb <Directory /home/git/gitweb> Options Indexes FollowSymlinks ExecCGI DirectoryIndex /cgi-bin/gitweb.cgi AllowOverride None </Directory> <Directory /home/git> Order allow,deny Allow from all AllowOverride None </Directory>
When you now hit http://yourserver.com/gitweb/ you should see your repositories listed. What you will notice though are the missing images and the missing stylesheet. As I like to keep things in one place I’ve moved them into the git home directory
sudo -u git mkdir /home/git/gitweb sudo cp /var/www/git* /home/git/gitweb sudo -u git chown -R git:git /home/git/gitweb
You will also need to make sure your project is accessible from the httpd user. Usually this means just making the top directory readable and executable for everyone.
sudo chmod a+rx /home/git/repositories/testproject.git
The stylesheet and images should get served now.
Now let’s setup permissions for accessing the repositories….