Skip to contentSkip to conversation

Installation instructions for gitweb?

PATCH In review Han-Wen Nienhuys 5 participants 8 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

I'm trying to get gitweb to serve my local repositories on the intranet here, but I am not successful in getting it to run. I got as far as getting gitweb page, containing no projects but only "403 forbidden - No projects found." I tried setting the projects_list to a directory, a subdirectory, a file with the projects to be published, etc.

Is there a guide on setting up gitweb for hare-brained people like me that don't know apache and don't know perl? In particular, the format of gitweb_conf.perl is not documented at all.

#1 lore raw

PATCH 1/1 gitweb: Add some installation notes in gitweb/INSTALL

Add some installation and configuration notes for gitweb in gitweb/INSTALL. Make use of filling gitweb configuration by Makefile.

It does not cover (yet?) all the configuration variables and options.

Some of contents duplicates information in gitweb/README file (it is referred from gitweb/INSTALL).

---

Quoted 9 lines · Han-Wen Nienhuys

I'm trying to get gitweb to serve my local repositories on the intranet here, but I am not successful in getting it to run. I got as far as getting gitweb page, containing no projects but only "403 forbidden - No projects found." I tried setting the projects_list to a directory, a subdirectory, a file with the projects to be published, etc.

Is there a guide on setting up gitweb for hare-brained people like me that don't know apache and don't know perl? In particular, the format of gitweb_conf.perl is not documented at all.

I hope that this addresses your questions.

---
We should probably think about what should go to gitweb/README file, and what should go to gitweb/INSTALL.

I haven't checked gitweb/README when writing gitweb/INSTALL, so it repeats some information from README (there are references to related sections in README).

Some information which is in gitweb/README should probably be in gitweb/INSTALL, but gitweb/INSTALL did not exist when the information was added.

Another issue is using cp' vs install' for gitweb installation.

 gitweb/INSTALL |  184 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 184 insertions(+), 0 deletions(-)
 create mode 100644 gitweb/INSTALL
gitweb/INSTALL new file +184 -0
new file mode 100644
index 0000000..371407d
@@ -0,0 +1,184 @@
+GIT web Interface (gitweb) Installation
+=======================================
+
+First you have to generate gitweb.cgi from gitweb.perl using
+"make gitweb/gitweb.cgi", then copy appropriate files (gitweb.cgi,
+gitweb.css, git-logo.png and git-favicon.png) to their destination.
+For example if git was (or is) installed with /usr prefix, you can do
+
+	$ make prefix=/usr gitweb/gitweb.cgi  ;# as yourself
+	# cp gitweb/git* /var/www/cgi-bin/    ;# as root
+
+Alternatively you can use autoconf generated ./configure script to
+set up path to git binaries (via config.mak.autogen), so you can write
+instead
+
+	$ make configure                     ;# as yourself
+	$ ./configure --prefix=/usr          ;# as yourself
+	$ make gitweb/gitweb.cgi             ;# as yourself
+	# cp gitweb/git* /var/www/cgi-bin/   ;# as root
+
+The above example assumes that your web server is configured to run
+[executable] files in /var/www/cgi-bin/ as server scripts (as CGI
+scripts).
+
+
+Build time configuration
+------------------------
+
+See also "How to configure gitweb for your local system" in README
+file for gitweb (in gitweb/README).
+
+- There are many configuration variables which affects building of
+  gitweb.cgi; see "default configuration for gitweb" section in main
+  (top dir) Makefile, and instructions for building gitweb/gitweb.cgi
+  target.
+
+  One of most important is where to find git wrapper binary. Gitweb
+  tries to find git wrapper at $(bindir)/git, so you have to set $bindir
+  when building gitweb.cgi, or $prefix from which $bindir is derived. If
+  you build and install gitweb together with the rest of git suite,
+  there should be no problems. Otherwise, if git was for example
+  installed from a binary package, you have to set $prefix (or $bindir)
+  accordingly.
+
+- Another important issue is where are git repositories you want to make
+  available to gitweb. By default gitweb search for repositories under
+  /pub/git; if you want to have projects somewhere else, like /home/git,
+  use GITWEB_PROJECTROOT build configuration variable.
+
+  By default all git repositories under projectroot are visible and
+  available to gitweb. List of projects is generated by default by
+  scanning the projectroot directory for git repositories. This can be
+  changed (configured) as described in "Gitweb repositories" section
+  below.
+
+  Note that gitweb deals directly with object database, and does not
+  need working directory; the name of the project is the name of its
+  repository object database, usually projectname.git for bare
+  repositories. If you want to provide gitweb access to non-bare (live)
+  repository, you can make projectname.git symbolic link under
+  projectroot linking to projectname/.git (but it is just
+  a suggestion).
+
+- You can control where gitweb tries to find its main CSS style file,
+  its favicon and logo with GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
+  build configuration variables. By default gitweb tries to find them
+  in the same directory as gitweb.cgi script.
+
+Build example
+~~~~~~~~~~~~~
+
+- To install gitweb to /var/www/cgi-bin/gitweb/ when git wrapper
+  is installed at /usr/local/bin/git and the repositories (projects)
+  we want to display are under /home/local/scm, you can do
+
+	make GITWEB_PROJECTROOT="/home/local/scm" \
+	     GITWEB_CSS="/gitweb/gitweb.css" \
+	     GITWEB_LOGO="/gitweb/git-logo.png" \
+	     GITWEB_FAVICON="/gitweb/git-favicon.png" \
+	     bindir=/usr/local/bin \
+	     gitweb/gitweb.cgi
+
+	cp -fv ~/git/gitweb/gitweb.{cgi,css} \
+	       ~/git/gitweb/git-{favicon,logo}.png \
+	     /var/www/cgi-bin/gitweb/
+
+
+Gitweb config file
+------------------
+
+See also "Runtime gitweb configuration" section in README file
+for gitweb (in gitweb/README).
+
+- You can configure gitweb further using gitweb configuration file;
+  by default it is file named gitweb_config.perl in the same place as
+  gitweb.cgi script. You can control default place for config file
+  using GITWEB_CONFIG build configuration variable, and you can set it
+  using GITWEB_CONFIG environmental variable.
+
+- Gitweb config file is [fragment] of perl code. You can set variables
+  using "our $variable = value"; text from "#" character until the end
+  of a line is ignored. See perlsyn(1) for details.
+
+  See the top of gitweb.perl file for examples of customizable options.
+
+
+Gitweb repositories:
+--------------------
+
+- By default all git repositories under projectroot are visible and
+  available to gitweb. List of projects is generated by default by
+  scanning the projectroot directory for git repositories (for object
+  databases to be more exact).
+
+  You can provide pre-generated list of [visible] repositories,
+  together with information about their owners (the project ownership
+  is taken from owner of repository directory otherwise), by setting
+  GITWEB_LIST build configuration variable (or $projects_list variable
+  in gitweb config file) to point to a plain file.
+
+  Each line of projects list file should consist of url-encoded path
+  to project repository database (relative to projectroot) separated
+  by space from url-encoded project owner; spaces in both project path
+  and project owner have to be encoded as either '%20' or '+'.
+
+  You can generate projects list index file using project_index action
+  (the 'TXT' link on projects list page) directly from gitweb.
+
+- By default even if project is not visible on projects list page, you
+  can view it nevertheless by hand-crafting gitweb URL. You can set
+  GITWEB_STRICT_EXPORT build configuration variable (or $strict_export
+  variable in gitweb config file) to only allow viewing of
+  repositories also shown on the overview page.
+
+- Alternatively, you can configure gitweb to only list and allow
+  viewing of the explicitly exported repositories, via
+  GITWEB_EXPORT_OK build configuration variable (or $export_ok
+  variable in gitweb config file). If it evaluates to true, gitweb
+  show repository only if this file exists in its object database
+  (if directory has the magic file $export_ok).
+
+
+Requirements
+------------
+
+ - Core git tools
+ - Perl
+ - Perl modules: CGI, Encode, Fcntl, File::Find, File::Basename.
+ - web server
+
+
+Example web server configuration
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+See also "Webserver configuration" section in README file for gitweb
+(in gitweb/README).
+
+
+- Apache2, gitweb installed as CGI script,
+  under /var/www/cgi-bin/
+
+	ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
+
+	<Directory "/var/www/cgi-bin">
+	    Options Indexes FollowSymlinks ExecCGI
+	    AllowOverride None
+	    Order allow,deny
+	    Allow from all
+	</Directory>
+
+- Apache2, gitweb installed as mod_perl legacy script,
+  under /var/www/perl/
+
+	Alias /perl "/var/www/perl"
+
+	<Directory "/var/www/perl">
+	    SetHandler perl-script
+	    PerlResponseHandler ModPerl::Registry
+	    PerlOptions +ParseHeaders
+	    Options Indexes FollowSymlinks +ExecCGI
+	    AllowOverride None
+	    Order allow,deny
+	    Allow from all
+	</Directory>
Signature · 1 line
1.5.0.5
#2 lore raw

Re: [PATCH] gitweb: Add some installation notes in gitweb/INSTALL

2007/3/24, Jakub Narebski <[email protected]>:

Quoted 6 lines

Add some installation and configuration notes for gitweb in gitweb/INSTALL. Make use of filling gitweb configuration by Makefile.

It does not cover (yet?) all the configuration variables and options.

I got it running with the help of the list, but this patch surely improves the state of the docs. Just one nit: it should give a small example of the desired syntax of the gitweb_conf.perl file

Signature · 1 line
Han-Wen Nienhuys - [email protected] - http://www.xs4all.nl/~hanwen
#3 lore raw

[PATCH/RFC] gitweb: Add example of config file and how to generate projects list to gitweb/INSTALL

Add simple example of config file (turning on and allowing override of a few %features). Also example config file and script to generate list of projects in a format that can be used as GITWEB_LIST / $projects_list.

---

Quoted 11 lines · Han-Wen Nienhuys

2007/3/24, Jakub Narebski <[email protected]>:

Quoted 6 lines

Add some installation and configuration notes for gitweb in gitweb/INSTALL. Make use of filling gitweb configuration by Makefile.

It does not cover (yet?) all the configuration variables and options.

I got it running with the help of the list, but this patch surely improves the state of the docs. Just one nit: it should give a small example of the desired syntax of the gitweb_conf.perl file

HTH

I'm not sure about example how to get projects list in the format suitable for gitweb. For example HTTP headers should be stripped from the projects_index gitweb.cgi output, but I don't remember proper sed invocation to skip all lines up to emty line/line containing only "\r".

 gitweb/INSTALL |   45 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 43 insertions(+), 2 deletions(-)
gitweb/INSTALL +43 -2
index 371407d..6328e26 100644
@@ -103,9 +103,25 @@ for gitweb (in gitweb/README).
 
   See the top of gitweb.perl file for examples of customizable options.
 
+Config file example
+~~~~~~~~~~~~~~~~~~~
 
-Gitweb repositories:
---------------------
+To enable blame, pickaxe search, and snapshot support, while allowing
+individual projects to turn them off, put the following in your
+GITWEB_CONFIG file:
+
+	$feature{'blame'}{'default'} = [1];
+	$feature{'blame'}{'override'} = 1;
+
+	$feature{'pickaxe'}{'default'} = [1];
+	$feature{'pickaxe'}{'override'} = 1;
+
+	$feature{'snapshot'}{'default'} = ['x-gzip', 'gz', 'gzip'];
+	$feature{'snapshot'}{'override'} = 1;
+
+
+Gitweb repositories
+-------------------
 
 - By default all git repositories under projectroot are visible and
   available to gitweb. List of projects is generated by default by
@@ -139,6 +155,31 @@ Gitweb repositories:
   show repository only if this file exists in its object database
   (if directory has the magic file $export_ok).
 
+Generating projects list using gitweb
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We assume that GITWEB_CONFIG has its default Makefile value, namely
+gitweb_config.perl. Put the following in gitweb_make_index.perl file:
+
+	$GITWEB_CONFIG = "gitweb_config.perl";
+	do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
+
+	$projects_list = $projectroot;
+
+Then create the following script to get list of project in the format
+suitable for GITWEB_LIST build configuration variable (or
+$projects_list variable in gitweb config):
+
+	#!/bin/sh
+
+	export GITWEB_CONFIG="gitweb_make_index.perl"
+	export GATEWAY_INTERFACE="CGI/1.1"
+	export HTTP_ACCEPT="*/*"
+	export REQUEST_METHOD="GET"
+	export QUERY_STRING="a=project_index"
+
+	perl -- /var/www/cgi-bin/gitweb.cgi
+
 
 Requirements
 ------------
Signature · 1 line
1.5.0.5
#4 lore raw
In reply to Han-Wen Nienhuys
Quoted 7 lines · Han-Wen Nienhuys

I'm trying to get gitweb to serve my local repositories on the intranet here, but I am not successful in getting it to run. I got as far as getting gitweb page, containing no projects but only "403 forbidden - No projects found." I tried setting the projects_list to a directory, a subdirectory, a file with the projects to be published, etc.

From looking at the code this error can mean quite a few things:

- you set $projectroot incorrectly
- you set $projects_list incorrectly
- you set $export_ok to something != "" and didn't create the necessary files
- your repositories lack HEAD refs (don't know how this could happen, though)

More diagnosis is difficult without knowing your exact setup.

Quoted 3 lines

Is there a guide on setting up gitweb for hare-brained people like me that don't know apache and don't know perl? In particular, the format of gitweb_conf.perl is not documented at all.

gitweb_conf.perl is just included as perl code. It is primarly useful for overriding the variables defined at the top of gitweb.cgi

Gruesse,

Signature · 2 lines
Frank Lichtenheld <[email protected]>
www: http://www.djpig.de/
#5 lore raw
Quoted 2 lines

gitweb_conf.perl is just included as perl code. It is primarly useful for overriding the variables defined at the top of gitweb.cgi

This explanation doesn't help me. Can you post an example snippet?

Signature · 1 line
Han-Wen Nienhuys - [email protected] - http://www.xs4all.nl/~hanwen
#6 lore raw
Quoted 4 lines · Han-Wen Nienhuys
Quoted 2 lines

gitweb_conf.perl is just included as perl code. It is primarly useful for overriding the variables defined at the top of gitweb.cgi

This explanation doesn't help me. Can you post an example snippet?

e.g. the default config file distributed in the Debian packages for git:

# path to git projects (<project>.git)
$projectroot = "/var/cache/git";
# 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
$stylesheet = "/gitweb.css";
# logo to use
$logo = "/git-logo.png";
# the 'favicon'
$favicon = "/git-favicon.png";

Gruesse,

Signature · 2 lines
Frank Lichtenheld <[email protected]>
www: http://www.djpig.de/
#7 lore raw
In reply to Han-Wen Nienhuys

Hi,

Quoted 9 lines · Han-Wen Nienhuys

I'm trying to get gitweb to serve my local repositories on the intranet here, but I am not successful in getting it to run. I got as far as getting gitweb page, containing no projects but only "403 forbidden - No projects found." I tried setting the projects_list to a directory, a subdirectory, a file with the projects to be published, etc.

Is there a guide on setting up gitweb for hare-brained people like me that don't know apache and don't know perl? In particular, the format of gitweb_conf.perl is not documented at all.

I never got to install gitweb myself. Instead, I used git-instaweb quite successfully...

Ciao,
Dscho