Skip to content

Commit 964ad92

Browse files
sylrgitster
authored andcommitted
gitweb multiple project roots documentation
This commit adds in the gitweb/README file a description of how to use gitweb with several project roots using apache virtualhost rewrite rules. Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c5e5f60 commit 964ad92

1 file changed

Lines changed: 64 additions & 3 deletions

File tree

gitweb/README

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,16 @@ If you want to have one URL for both gitweb and your http://
312312
repositories, you can configure apache like this:
313313

314314
<VirtualHost *:80>
315-
ServerName git.example.org
316-
DocumentRoot /pub/git
317-
SetEnv GITWEB_CONFIG /etc/gitweb.conf
315+
ServerName git.example.org
316+
DocumentRoot /pub/git
317+
SetEnv GITWEB_CONFIG /etc/gitweb.conf
318+
319+
# turning on mod rewrite
318320
RewriteEngine on
321+
319322
# make the front page an internal rewrite to the gitweb script
320323
RewriteRule ^/$ /cgi-bin/gitweb.cgi
324+
321325
# make access for "dumb clients" work
322326
RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
323327
</VirtualHost>
@@ -343,6 +347,63 @@ something like the following in your gitweb.conf (or gitweb_config.perl) file:
343347
$home_link = "/";
344348

345349

350+
Webserver configuration with multiple projects' root
351+
----------------------------------------------------
352+
353+
If you want to use gitweb with several project roots you can edit your apache
354+
virtual host and gitweb.conf configuration files like this :
355+
356+
virtual host configuration :
357+
358+
<VirtualHost *:80>
359+
ServerName git.example.org
360+
DocumentRoot /pub/git
361+
SetEnv GITWEB_CONFIG /etc/gitweb.conf
362+
363+
# turning on mod rewrite
364+
RewriteEngine on
365+
366+
# make the front page an internal rewrite to the gitweb script
367+
RewriteRule ^/$ /cgi-bin/gitweb.cgi [QSA,L,PT]
368+
369+
# look for a public_git folder in unix users' home
370+
# http://git.example.org/~<user>/
371+
RewriteRule ^/\~([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
372+
373+
# http://git.example.org/+<user>/
374+
#RewriteRule ^/\+([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
375+
376+
# http://git.example.org/user/<user>/
377+
#RewriteRule ^/user/([^\/]+)/(gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT]
378+
379+
# defined list of project roots
380+
RewriteRule ^/scm(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT]
381+
RewriteRule ^/var(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT]
382+
383+
# make access for "dumb clients" work
384+
RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
385+
</VirtualHost>
386+
387+
gitweb.conf configuration :
388+
389+
$projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git";
390+
391+
These configurations enable two things. First, each unix user (<user>) of the
392+
server will be able to browse through gitweb git repositories found in
393+
~/public_git/ with the following url : http://git.example.org/~<user>/
394+
395+
If you do not want this feature on your server just remove the second rewrite rule.
396+
397+
If you already use mod_userdir in your virtual host or you don't want to use
398+
the '~' as first character just comment or remove the second rewrite rule and
399+
uncomment one of the following according to what you want.
400+
401+
Second, repositories found in /pub/scm/ and /var/git/ will be accesible
402+
through http://git.example.org/scm/ and http://git.example.org/var/.
403+
You can add as many project roots as you want by adding rewrite rules like the
404+
third and the fourth.
405+
406+
346407
PATH_INFO usage
347408
-----------------------
348409
If you enable PATH_INFO usage in gitweb by putting

0 commit comments

Comments
 (0)