Install GitWeb to work with Gitosis Installation

First create a virtual host for gitweb in apache


DocumentRoot /home/gitweb.bizhat.com/public_html/
ServerName gitweb.bizhat.com
CustomLog /var/log/httpd/gitweb.bizhat.com.log combined
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi


    AllowOverride All
    Options All
    Order allow,deny
    Allow from all
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.* /gitweb.cgi/$0 [L,PT]


NOTE: since wordpress is not converting < tag in virtual host entry, i have uploaded actual virtual host used here http://blog.hostonnet.com/files_hon/gitweb.conf

GitWeb is part of git installation. If you have installed git from source, you will see gitweb folder inside git source.

Copy gitweb to docroot of your web site.

mkdir -p /home/gitweb.bizhat.com/public_html/
cd /usr/local/src/git*/gitweb
cp -Rf * /home/gitweb.bizhat.com/public_html/

After visiting the web site, i got following error

 Can't locate CGI.pm in @INC (@INC contains:

So i installed perl-CGI

yum install perl-CGI

Now sites start working, but did not show any repository.

Now you need to edit gitweb.cgi and set path to repository.

Edit gitweb.cgi

vi gitweb.cgi

Find

our $projectroot = "/pub/git";

Replace with your gitosis install path

our $projectroot = "/home/git/repositories/";

Now gitweb will show all repos.

To show only selected projects in gitweb, edit gitweb.cgi

Find

our $projects_list = "";

Replace with

our $projects_list = "projects.txt";

Now create a file “projects.txt” with name of repos you want to show in gitweb.

root@server70 [/home/gitweb.bizhat.com/public_html/]# cat projects.txt
website.git
HostOnNet 

billing.git
HostOnNet 

cms.git
HostOnNet 

root@server70 [/home/gitweb.bizhat.com/public_html/]#

Posted in Git