Make sure these GIT packages are installed:

$ aptitude install git git-core gitk gitweb

Assume the default apache web server is /var/www/ ,
gitweb is the directory I want to install gitweb:

$ cd /var/www/
$ mkdir gitweb
$ cd gitweb

copy gitweb graphics and stylesheets(git-favicon.png git-logo.png gitweb.css) to its directory, their path should correspond to what states in /etc/gitweb.conf:

$ cd /var/www/gitweb/
$ cp /usr/share/gitweb/* .

add gitweb directory to apache2 configuration by creating a “gitweb” file inside apache conf.d directory:

$ vi /etc/apache/conf.d/gitweb

Paste the following text and modify if your path is different:

Alias /gitweb /var/www/gitweb

Options Indexes FollowSymlinks ExecCGI
DirectoryIndex /cgi-bin/gitweb.cgi
AllowOverride None

Modify gitweb.conf, assuming the public GIT repositories are located in /var/www/repo/

$ vi /etc/gitweb.conf

$projectroot = “/var/www/repo/”;

# directory to use for temp files
$git_temp = “/tmp”;

# target of the home link on top of all pages
#$home_link = $my_uri || “/”;

# html text to include at home page
$home_text = “indextext.html”;

# file with project list; by default, simply scan the projectroot dir.
$projects_list = $projectroot;

# stylesheet to use
# I took off the prefix / of the following path to put these files inside gitweb directory directly
$stylesheet = “gitweb.css”;

# logo to use
$logo = “git-logo.png”;

# the ‘favicon’
$favicon = “git-favicon.png”;

restart apache2 web server:

$ sudo /etc/init.d/apache2 restart

Now you should be able to view gitweb listing all GIT projects under /var/www/repo/:
http://localhost/gitweb