Setting up gitweb/apache2

I have recently began storing code, that I write on a local server I have at home.

I was hoping to start a gitweb instance at home so I can see commits and track progress with my other team mates.

I have tried server tutorials online with no luck. I would like gitweb to be accessed by

I would like my code to be place in /code/git

I would appreciate any help! Please try to be explicit as possible, because I clearly dont know what i am doing. I have read tons of articles.

Please and thank you.

2 Answers

The gitweb part:

You have to install the package gitweb with sudo apt-get install gitweb

Then you have to edit the apache gitweb config file

$EDITOR /etc/apache2/conf.d/gitweb

change the line Alias /gitweb /usr/share/gitwebto

Alias /git /usr/share/gitweb

open the /etc/gitweb.conf file:

you have to change the line$projectroot ".." to$projectroot "/code/git"

and change any other line containing /gitweb to /gitfor example

$stylesheet = "/gitweb/gitweb.css";

to

$stylesheet = "/git/gitweb.css";

then reload you apache webserver with sudo /etc/init.d/apache2 horse-reload

The GIT part itself:

I STRONGLY recommend the use of gitosis ()

REMEMBER if you use gitosis the line $projectroot in /etc/gitweb.conf has to be

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

You can find detailed information on howto setup gitosis at

describing the full gitosis setup is too long for this answer.

If you need more help on gitosis drop me a comment

To fix apache permission problems, it might be necessary to do:

adduser www-data git
chgrp -R git /home/git/repositories
4

Here is what I did to setup gitweb on Ubuntu 14.04 - with SSL and authentication of system users with pwauth. By default, gitweb uses a /etc/gitweb.conf, which expects git projects in /var/lib/git.

So I tried to put my git repos in here, so in this example we don't have to change /etc/gitweb.conf - my /var/lib/git looks like this:

$ ls -la /var/lib/git/
total 12
drwxrwxrwx 3 root root 4096 Apr 9 16:01 .
drwxr-xr-x 75 root root 4096 Apr 7 17:31 ..
lrwxrwxrwx 1 myuser myuser 28 Apr 9 16:01 gitweb.cgi -> /usr/share/gitweb/gitweb.cgi
drwxrwsr-x 7 myuser www-data 4096 Apr 10 17:50 testrepo.git

So, beside your repos, you would need to symlink /usr/share/gitweb/gitweb.cgi in this directory too...

Then, you can use the following as /etc/apache2/sites-available/gitw-ssl.conf:

<IfModule mod_ssl.c> <VirtualHost _default_:443> ServerAdmin webmaster@localhost ServerName localhost HeaderName HEADER DocumentRoot /var/www/html LogLevel info ErrorLog ${APACHE_LOG_DIR}/error-gw.log CustomLog ${APACHE_LOG_DIR}/access-gw.log combined SSLEngine on SSLCertificateFile /etc/apache2/ssl/my.crt SSLCertificateKeyFile /etc/apache2/ssl/my.key <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory /usr/lib/cgi-bin> SSLOptions +StdEnvVars </Directory> <IfModule mod_authnz_external.c> # old style: AddExternalAuth pwauth /usr/sbin/pwauth SetExternalAuthMethod pwauth pipe # new style: #DefineExternalAuth pwauth pipe /usr/sbin/pwauth </IfModule> # as more specific, /gitweb/static should go first Alias /gitweb/static /usr/share/gitweb/static Alias /gitweb /var/lib/git # gitweb.cgi alias is no dice - symlink is needed: Alias gitweb.cgi /usr/share/gitweb/gitweb.cgi <Directory /var/lib/git> Options +FollowSymlinks +ExecCGI SSLRequireSSL AuthType basic AuthName "Private git repository" AuthBasicProvider external AuthExternal pwauth Require valid-user AddHandler cgi-script .cgi DirectoryIndex gitweb.cgi </Directory> ScriptAlias /git/ /usr/lib/git-core/git-http-backend/ <Directory "/usr/lib/git-core/"> SetEnv GIT_PROJECT_ROOT /var/lib/git SetEnv GIT_HTTP_EXPORT_ALL Options +ExecCGI SSLRequireSSL AuthType basic AuthName "Private git repository" AuthBasicProvider external AuthExternal pwauth Require valid-user </Directory> </VirtualHost>
</IfModule>

And finally you can do:

# not sure if also `fcgid auth_digest` are needed:
sudo a2enmod ssl cgi alias env rewrite
sudo a2ensite gitw-ssl.conf
# if not `reload`, use `restart`:
sudo service apache2 reload

After this, gitweb should be available on (for instance, ); and you should be able to clone (in case of a self-signed SSL certificate) with:

GIT_SSL_NO_VERIFY=1 git clone 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like