gitweb / INSTALLon commit Merge branch 'js/mingw-rename-fix' (8c1944d)
   1GIT web Interface (gitweb) Installation
   2=======================================
   3
   4First you have to generate gitweb.cgi from gitweb.perl using
   5"make gitweb/gitweb.cgi", then copy appropriate files (gitweb.cgi,
   6gitweb.css, git-logo.png and git-favicon.png) to their destination.
   7For example if git was (or is) installed with /usr prefix, you can do
   8
   9        $ make prefix=/usr gitweb/gitweb.cgi  ;# as yourself
  10        # cp gitweb/git* /var/www/cgi-bin/    ;# as root
  11
  12Alternatively you can use autoconf generated ./configure script to
  13set up path to git binaries (via config.mak.autogen), so you can write
  14instead
  15
  16        $ make configure                     ;# as yourself
  17        $ ./configure --prefix=/usr          ;# as yourself
  18        $ make gitweb/gitweb.cgi             ;# as yourself
  19        # cp gitweb/git* /var/www/cgi-bin/   ;# as root
  20
  21The above example assumes that your web server is configured to run
  22[executable] files in /var/www/cgi-bin/ as server scripts (as CGI
  23scripts).
  24
  25
  26Build time configuration
  27------------------------
  28
  29See also "How to configure gitweb for your local system" in README
  30file for gitweb (in gitweb/README).
  31
  32- There are many configuration variables which affect building of
  33  gitweb.cgi; see "default configuration for gitweb" section in main
  34  (top dir) Makefile, and instructions for building gitweb/gitweb.cgi
  35  target.
  36
  37  One of the most important is where to find the git wrapper binary. Gitweb
  38  tries to find the git wrapper at $(bindir)/git, so you have to set $bindir
  39  when building gitweb.cgi, or $prefix from which $bindir is derived. If
  40  you build and install gitweb together with the rest of the git suite,
  41  there should be no problems. Otherwise, if git was for example
  42  installed from a binary package, you have to set $prefix (or $bindir)
  43  accordingly.
  44
  45- Another important issue is where are git repositories you want to make
  46  available to gitweb. By default gitweb searches for repositories under
  47  /pub/git; if you want to have projects somewhere else, like /home/git,
  48  use GITWEB_PROJECTROOT build configuration variable.
  49
  50  By default all git repositories under projectroot are visible and
  51  available to gitweb. The list of projects is generated by default by
  52  scanning the projectroot directory for git repositories. This can be
  53  changed (configured) as described in "Gitweb repositories" section
  54  below.
  55
  56  Note that gitweb deals directly with the object database, and does not
  57  need a working directory; the name of the project is the name of its
  58  repository object database, usually projectname.git for bare
  59  repositories. If you want to provide gitweb access to non-bare (live)
  60  repositories, you can make projectname.git a symbolic link under
  61  projectroot linking to projectname/.git (but it is just
  62  a suggestion).
  63
  64- You can control where gitweb tries to find its main CSS style file,
  65  its favicon and logo with the GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
  66  build configuration variables. By default gitweb tries to find them
  67  in the same directory as gitweb.cgi script.
  68
  69Build example
  70~~~~~~~~~~~~~
  71
  72- To install gitweb to /var/www/cgi-bin/gitweb/ when git wrapper
  73  is installed at /usr/local/bin/git and the repositories (projects)
  74  we want to display are under /home/local/scm, you can do
  75
  76        make GITWEB_PROJECTROOT="/home/local/scm" \
  77             GITWEB_CSS="/gitweb/gitweb.css" \
  78             GITWEB_LOGO="/gitweb/git-logo.png" \
  79             GITWEB_FAVICON="/gitweb/git-favicon.png" \
  80             bindir=/usr/local/bin \
  81             gitweb/gitweb.cgi
  82
  83        cp -fv ~/git/gitweb/gitweb.{cgi,css} \
  84               ~/git/gitweb/git-{favicon,logo}.png \
  85             /var/www/cgi-bin/gitweb/
  86
  87
  88Gitweb config file
  89------------------
  90
  91See also "Runtime gitweb configuration" section in README file
  92for gitweb (in gitweb/README).
  93
  94- You can configure gitweb further using the gitweb configuration file;
  95  by default this is a file named gitweb_config.perl in the same place as
  96  gitweb.cgi script. You can control the default place for the config file
  97  using the GITWEB_CONFIG build configuration variable, and you can set it
  98  using the GITWEB_CONFIG environment variable. If this file does not
  99  exist, gitweb looks for a system-wide configuration file, normally
 100  /etc/gitweb.conf. You can change the default using the
 101  GITWEB_CONFIG_SYSTEM build configuration variable, and override it
 102  through the GITWEB_CONFIG_SYSTEM environment variable.
 103
 104- The gitweb config file is a fragment of perl code. You can set variables
 105  using "our $variable = value"; text from "#" character until the end
 106  of a line is ignored. See perlsyn(1) for details.
 107
 108  See the top of gitweb.perl file for examples of customizable options.
 109
 110Config file example
 111~~~~~~~~~~~~~~~~~~~
 112
 113To enable blame, pickaxe search, and snapshot support, while allowing
 114individual projects to turn them off, put the following in your
 115GITWEB_CONFIG file:
 116
 117        $feature{'blame'}{'default'} = [1];
 118        $feature{'blame'}{'override'} = 1;
 119
 120        $feature{'pickaxe'}{'default'} = [1];
 121        $feature{'pickaxe'}{'override'} = 1;
 122
 123        $feature{'snapshot'}{'default'} = ['zip', 'tgz'];
 124        $feature{'snapshot'}{'override'} = 1;
 125
 126
 127Gitweb repositories
 128-------------------
 129
 130- By default all git repositories under projectroot are visible and
 131  available to gitweb. The list of projects is generated by default by
 132  scanning the projectroot directory for git repositories (for object
 133  databases to be more exact).
 134
 135  You can provide a pre-generated list of [visible] repositories,
 136  together with information about their owners (the project ownership
 137  defaults to the owner of the repository directory otherwise), by setting
 138  the GITWEB_LIST build configuration variable (or the $projects_list
 139  variable in the gitweb config file) to point to a plain file.
 140
 141  Each line of the projects list file should consist of the url-encoded path
 142  to the project repository database (relative to projectroot), followed
 143  by the url-encoded project owner on the same line (separated by a space).
 144  Spaces in both project path and project owner have to be encoded as either
 145  '%20' or '+'.
 146
 147  Other characters that have to be url-encoded, i.e. replaced by '%'
 148  followed by two-digit character number in octal, are: other whitespace
 149  characters (because they are field separator in a record), plus sign '+'
 150  (because it can be used as replacement for spaces), and percent sign '%'
 151  (which is used for encoding / escaping).
 152
 153  You can generate the projects list index file using the project_index
 154  action (the 'TXT' link on projects list page) directly from gitweb.
 155
 156- By default, even if a project is not visible on projects list page, you
 157  can view it nevertheless by hand-crafting a gitweb URL. You can set the
 158  GITWEB_STRICT_EXPORT build configuration variable (or the $strict_export
 159  variable in the gitweb config file) to only allow viewing of
 160  repositories also shown on the overview page.
 161
 162- Alternatively, you can configure gitweb to only list and allow
 163  viewing of the explicitly exported repositories, via the
 164  GITWEB_EXPORT_OK build configuration variable (or the $export_ok
 165  variable in gitweb config file). If it evaluates to true, gitweb
 166  shows repositories only if this file exists in its object database
 167  (if directory has the magic file named $export_ok).
 168
 169- Finally, it is possible to specify an arbitrary perl subroutine that
 170  will be called for each project to determine if it can be exported.
 171  The subroutine receives an absolute path to the project as its only
 172  parameter.
 173
 174  For example, if you use mod_perl to run the script, and have dumb
 175  http protocol authentication configured for your repositories, you
 176  can use the following hook to allow access only if the user is
 177  authorized to read the files:
 178
 179    $export_auth_hook = sub {
 180        use Apache2::SubRequest ();
 181        use Apache2::Const -compile => qw(HTTP_OK);
 182        my $path = "$_[0]/HEAD";
 183        my $r    = Apache2::RequestUtil->request;
 184        my $sub  = $r->lookup_file($path);
 185        return $sub->filename eq $path
 186            && $sub->status == Apache2::Const::HTTP_OK;
 187    };
 188
 189
 190Generating projects list using gitweb
 191~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 192
 193We assume that GITWEB_CONFIG has its default Makefile value, namely
 194gitweb_config.perl. Put the following in gitweb_make_index.perl file:
 195
 196        $GITWEB_CONFIG = "gitweb_config.perl";
 197        do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
 198
 199        $projects_list = $projectroot;
 200
 201Then create the following script to get list of project in the format
 202suitable for GITWEB_LIST build configuration variable (or
 203$projects_list variable in gitweb config):
 204
 205        #!/bin/sh
 206
 207        export GITWEB_CONFIG="gitweb_make_index.perl"
 208        export GATEWAY_INTERFACE="CGI/1.1"
 209        export HTTP_ACCEPT="*/*"
 210        export REQUEST_METHOD="GET"
 211        export QUERY_STRING="a=project_index"
 212
 213        perl -- /var/www/cgi-bin/gitweb.cgi
 214
 215
 216Requirements
 217------------
 218
 219 - Core git tools
 220 - Perl
 221 - Perl modules: CGI, Encode, Fcntl, File::Find, File::Basename.
 222 - web server
 223
 224
 225Example web server configuration
 226~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 227
 228See also "Webserver configuration" section in README file for gitweb
 229(in gitweb/README).
 230
 231
 232- Apache2, gitweb installed as CGI script,
 233  under /var/www/cgi-bin/
 234
 235        ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
 236
 237        <Directory "/var/www/cgi-bin">
 238            Options Indexes FollowSymlinks ExecCGI
 239            AllowOverride None
 240            Order allow,deny
 241            Allow from all
 242        </Directory>
 243
 244- Apache2, gitweb installed as mod_perl legacy script,
 245  under /var/www/perl/
 246
 247        Alias /perl "/var/www/perl"
 248
 249        <Directory "/var/www/perl">
 250            SetHandler perl-script
 251            PerlResponseHandler ModPerl::Registry
 252            PerlOptions +ParseHeaders
 253            Options Indexes FollowSymlinks +ExecCGI
 254            AllowOverride None
 255            Order allow,deny
 256            Allow from all
 257        </Directory>