Setting up of GitWeb : Web interface for Git

          Setup a web Interface for Git ( GitWeb With Ldap Authentication )

Pre Requests :-

1) Git and Gitolite should be installed ( Refer here )
2) Git web is installed using yum
3) You should have the root privileges and webserver should be Apache .If you are fine with the above requirements then lets proceed !!

==> Add user ‘apache’ and ‘gitolite’ into the group ‘gitolite’

# usermod -a -G gitolite apache
# usermod -a -G gitolite gitolite

# id apache
uid=48(apache) gid=48(apache) groups=48(apache),157(gitolite)
# id gitolite
uid=103(gitolite) gid=157(gitolite) groups=157(gitolite)

==> Change $REPO_UMASK config in ‘.gitolite.rc’ file to 0027 around line 30

# cd /srv/git/
# cat .gitolite.rc | grep REPO_UMASK
$REPO_UMASK = 0027;

==> Edit /etc/gitweb.conf and set the value for $projectroot and $projects_list
$projectroot = “/srv/git/repositories”;
$projects_list = “/srv/git/projects.list”;
@git_base_url_list = qw(ssh://[email protected]); # replace gitserver with your gitserver ip

Apache Virutal Host section ( Ldap authentication )

<VirtualHost  *:80>
ServerAdmin [email protected]
DocumentRoot /usr/share/gitweb
<Directory /usr/share/gitweb>
Options FollowSymLinks ExecCGI
DirectoryIndex gitweb.cgi
AddHandler cgi-script cgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
<Location "/">
AuthType Basic
AuthName "Git Authentication"
AuthBasicProvider ldap
AuthzLDAPAuthoritative off
AuthLDAPURL ldap://,dc=com?uid
Require valid-user

==> Also we need to provide read access to gitweb user to all the repo’s using gitolite.conf as follows

#  cat gitolite.conf
@developers = root hari william
@qa = jack lilly
repo    gitolite-admin
RW+ = @developers
repo    new-project
R = @qa  gitweb daemon
repo    testing
RW+ = @all
R =  gitweb daemon

==> Restart Apache

Now just access the ip/hostname of the git server in browser , you can browse the repo’s using the ldap credentials.

Common Errors : –

1)  (13)Permission denied: exec of ‘/usr/share/gitweb/gitweb.cgi’ failed .Premature end of script headers: gitweb.cgi

Fix : –

chgrp apache /usr/sbin/suexec
chgrp apache /usr/sbin/suexec
cp -r /usr/share/gitweb /var/www
chown -R gitolite.gitolite /var/www

2)      404 – no projects found gitweb

Fix : –    chmod -Rf g+rx /srv/git