gitweb / INSTALLon commit t4014: clean up format.thread config after each test (e810715)
   1GIT web Interface (gitweb) Installation
   2=======================================
   3
   4First you have to generate gitweb.cgi from gitweb.perl using
   5"make gitweb", then "make install-gitweb" appropriate files
   6(gitweb.cgi, gitweb.js, gitweb.css, git-logo.png and git-favicon.png)
   7to their destination. For example if git was (or is) installed with
   8/usr prefix and gitwebdir is /var/www/cgi-bin, you can do
   9
  10        $ make prefix=/usr gitweb                            ;# as yourself
  11        # make gitwebdir=/var/www/cgi-bin install-gitweb     ;# as root
  12
  13Alternatively you can use autoconf generated ./configure script to
  14set up path to git binaries (via config.mak.autogen), so you can write
  15instead
  16
  17        $ make configure                     ;# as yourself
  18        $ ./configure --prefix=/usr          ;# as yourself
  19        $ make gitweb                        ;# as yourself
  20        # make gitwebdir=/var/www/cgi-bin \
  21               install-gitweb                ;# as root
  22
  23The above example assumes that your web server is configured to run
  24[executable] files in /var/www/cgi-bin/ as server scripts (as CGI
  25scripts).
  26
  27
  28Requirements
  29------------
  30
  31 - Core git tools
  32 - Perl
  33 - Perl modules: CGI, Encode, Fcntl, File::Find, File::Basename.
  34 - web server
  35
  36The following optional Perl modules are required for extra features
  37 - Digest::MD5 - for gravatar support
  38 - CGI::Fast and FCGI - for running gitweb as FastCGI script
  39 - HTML::TagCloud - for fancy tag cloud in project list view
  40 - HTTP::Date or Time::ParseDate - to support If-Modified-Since for feeds
  41
  42
  43Build time configuration
  44------------------------
  45
  46See also "How to configure gitweb for your local system" section below.
  47
  48- There are many configuration variables which affect building of
  49  gitweb.cgi; see "default configuration for gitweb" section in main
  50  (top dir) Makefile, and instructions for building gitweb target.
  51
  52  One of the most important is where to find the git wrapper binary. Gitweb
  53  tries to find the git wrapper at $(bindir)/git, so you have to set $bindir
  54  when building gitweb.cgi, or $prefix from which $bindir is derived. If
  55  you build and install gitweb together with the rest of the git suite,
  56  there should be no problems. Otherwise, if git was for example
  57  installed from a binary package, you have to set $prefix (or $bindir)
  58  accordingly.
  59
  60- Another important issue is where are git repositories you want to make
  61  available to gitweb. By default gitweb searches for repositories under
  62  /pub/git; if you want to have projects somewhere else, like /home/git,
  63  use GITWEB_PROJECTROOT build configuration variable.
  64
  65  By default all git repositories under projectroot are visible and
  66  available to gitweb. The list of projects is generated by default by
  67  scanning the projectroot directory for git repositories. This can be
  68  changed (configured) as described in "Gitweb repositories" section
  69  below.
  70
  71  Note that gitweb deals directly with the object database, and does not
  72  need a working directory; the name of the project is the name of its
  73  repository object database, usually projectname.git for bare
  74  repositories. If you want to provide gitweb access to non-bare (live)
  75  repositories, you can make projectname.git a symbolic link under
  76  projectroot linking to projectname/.git (but it is just
  77  a suggestion).
  78
  79- You can control where gitweb tries to find its main CSS style file,
  80  its JavaScript file, its favicon and logo with the GITWEB_CSS, GITWEB_JS
  81  GITWEB_FAVICON and GITWEB_LOGO build configuration variables. By default
  82  gitweb tries to find them in the same directory as gitweb.cgi script.
  83
  84- You can optionally generate minified versions of gitweb.js and gitweb.css
  85  by defining the JSMIN and CSSMIN build configuration variables. By default
  86  the non-minified versions will be used. NOTE: if you enable this option,
  87  substitute gitweb.min.js and gitweb.min.css for all uses of gitweb.js and
  88  gitweb.css in the help files.
  89
  90
  91How to configure gitweb for your local system
  92---------------------------------------------
  93
  94You can specify the following configuration variables when building GIT:
  95
  96 * GIT_BINDIR
  97   Points where to find the git executable.  You should set it up to
  98   the place where the git binary was installed (usually /usr/bin) if you
  99   don't install git from sources together with gitweb.  [Default: $(bindir)]
 100 * GITWEB_SITENAME
 101   Shown in the title of all generated pages, defaults to the server name
 102   (SERVER_NAME CGI environment variable) if not set. [No default]
 103 * GITWEB_PROJECTROOT
 104   The root directory for all projects shown by gitweb. Must be set
 105   correctly for gitweb to find repositories to display.  See also
 106   "Gitweb repositories" in the INSTALL file for gitweb.  [Default: /pub/git]
 107 * GITWEB_PROJECT_MAXDEPTH
 108   The filesystem traversing limit for getting the project list; the number
 109   is taken as depth relative to the projectroot.  It is used when
 110   GITWEB_LIST is a directory (or is not set; then project root is used).
 111   This is meant to speed up project listing on large work trees by limiting
 112   search depth.  [Default: 2007]
 113 * GITWEB_LIST
 114   Points to a directory to scan for projects (defaults to project root
 115   if not set / if empty) or to a file with explicit listing of projects
 116   (together with projects' ownership). See "Generating projects list
 117   using gitweb" in INSTALL file for gitweb to find out how to generate
 118   such file from scan of a directory. [No default, which means use root
 119   directory for projects]
 120 * GITWEB_EXPORT_OK
 121   Show repository only if this file exists (in repository).  Only
 122   effective if this variable evaluates to true.  [No default / Not set]
 123 * GITWEB_STRICT_EXPORT
 124   Only allow viewing of repositories also shown on the overview page.
 125   This for example makes GITWEB_EXPORT_OK to decide if repository is
 126   available and not only if it is shown.  If GITWEB_LIST points to
 127   file with list of project, only those repositories listed would be
 128   available for gitweb.  [No default]
 129 * GITWEB_HOMETEXT
 130   Points to an .html file which is included on the gitweb project
 131   overview page ('projects_list' view), if it exists.  Relative to
 132   gitweb.cgi script.  [Default: indextext.html]
 133 * GITWEB_SITE_HEADER
 134   Filename of html text to include at top of each page.  Relative to
 135   gitweb.cgi script.  [No default]
 136 * GITWEB_SITE_FOOTER
 137   Filename of html text to include at bottom of each page.  Relative to
 138   gitweb.cgi script.  [No default]
 139 * GITWEB_HOME_LINK_STR
 140   String of the home link on top of all pages, leading to $home_link
 141   (usually main gitweb page, which means projects list).  Used as first
 142   part of gitweb view "breadcrumb trail": <home> / <project> / <view>.
 143   [Default: projects]
 144 * GITWEB_SITENAME
 145   Name of your site or organization to appear in page titles.  Set it
 146   to something descriptive for clearer bookmarks etc.  If not set
 147   (if empty) gitweb uses "$SERVER_NAME Git", or "Untitled Git" if
 148   SERVER_NAME CGI environment variable is not set (e.g. if running
 149   gitweb as standalone script).  [No default]
 150 * GITWEB_BASE_URL
 151   Git base URLs used for URL to where fetch project from, i.e. full
 152   URL is "$git_base_url/$project".  Shown on projects summary page.
 153   Repository URL for project can be also configured per repository; this
 154   takes precedence over URLs composed from base URL and a project name.
 155   Note that you can setup multiple base URLs (for example one for
 156   git:// protocol access, another for http:// access) from the gitweb
 157   config file.  [No default]
 158 * GITWEB_CSS
 159   Points to the location where you put gitweb.css on your web server
 160   (or to be more generic, the URI of gitweb stylesheet).  Relative to the
 161   base URI of gitweb.  Note that you can setup multiple stylesheets from
 162   the gitweb config file.  [Default: static/gitweb.css (or
 163   static/gitweb.min.css if the CSSMIN variable is defined / CSS minifier
 164   is used)]
 165 * GITWEB_JS
 166   Points to the location where you put gitweb.js on your web server
 167   (or to be more generic URI of JavaScript code used by gitweb).
 168   Relative to base URI of gitweb.  [Default: static/gitweb.js (or
 169   static/gitweb.min.js if JSMIN build variable is defined / JavaScript
 170   minifier is used)]
 171 * CSSMIN, JSMIN
 172   Invocation of a CSS minifier or a JavaScript minifier, respectively,
 173   working as a filter (source on standard input, minified result on
 174   standard output).  If set, it is used to generate a minified version of
 175   'static/gitweb.css' or 'static/gitweb.js', respectively.  *Note* that
 176   minified files would have *.min.css and *.min.js extension, which is
 177   important if you also set GITWEB_CSS and/or GITWEB_JS.  [No default]
 178 * GITWEB_LOGO
 179   Points to the location where you put git-logo.png on your web server
 180   (or to be more generic URI of logo, 72x27 size, displayed in top right
 181   corner of each gitweb page, and used as logo for Atom feed).  Relative
 182   to base URI of gitweb.  [Default: static/git-logo.png]
 183 * GITWEB_FAVICON
 184   Points to the location where you put git-favicon.png on your web server
 185   (or to be more generic URI of favicon, assumed to be image/png type;
 186   web browsers that support favicons (website icons) may display them
 187   in the browser's URL bar and next to site name in bookmarks).  Relative
 188   to base URI of gitweb.  [Default: static/git-favicon.png]
 189 * GITWEB_CONFIG
 190   This Perl file will be loaded using 'do' and can be used to override any
 191   of the options above as well as some other options -- see the "Runtime
 192   gitweb configuration" section below, and top of 'gitweb.cgi' for their
 193   full list and description.  If the environment variable GITWEB_CONFIG
 194   is set when gitweb.cgi is executed, then the file specified in the
 195   environment variable will be loaded instead of the file specified
 196   when gitweb.cgi was created.  [Default: gitweb_config.perl]
 197 * GITWEB_CONFIG_SYSTEM
 198   This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG
 199   does not exist.  If the environment variable GITWEB_CONFIG_SYSTEM is set
 200   when gitweb.cgi is executed, then the file specified in the environment
 201   variable will be loaded instead of the file specified when gitweb.cgi was
 202   created.  [Default: /etc/gitweb.conf]
 203 * HIGHLIGHT_BIN
 204   Path to the highlight executable to use (must be the one from
 205   http://www.andre-simon.de due to assumptions about parameters and output).
 206   Useful if highlight is not installed on your webserver's PATH.
 207   [Default: highlight]
 208
 209Build example
 210~~~~~~~~~~~~~
 211
 212- To install gitweb to /var/www/cgi-bin/gitweb/, when git wrapper
 213  is installed at /usr/local/bin/git, the repositories (projects)
 214  we want to display are under /home/local/scm, and you do not use
 215  minifiers, you can do
 216
 217        make GITWEB_PROJECTROOT="/home/local/scm" \
 218             GITWEB_JS="gitweb/static/gitweb.js" \
 219             GITWEB_CSS="gitweb/static/gitweb.css" \
 220             GITWEB_LOGO="gitweb/static/git-logo.png" \
 221             GITWEB_FAVICON="gitweb/static/git-favicon.png" \
 222             bindir=/usr/local/bin \
 223             gitweb
 224
 225        make gitwebdir=/var/www/cgi-bin/gitweb install-gitweb
 226
 227
 228Gitweb config file
 229------------------
 230
 231See also "Runtime gitweb configuration" section in README file
 232for gitweb (in gitweb/README).
 233
 234- You can configure gitweb further using the gitweb configuration file;
 235  by default this is a file named gitweb_config.perl in the same place as
 236  gitweb.cgi script. You can control the default place for the config file
 237  using the GITWEB_CONFIG build configuration variable, and you can set it
 238  using the GITWEB_CONFIG environment variable. If this file does not
 239  exist, gitweb looks for a system-wide configuration file, normally
 240  /etc/gitweb.conf. You can change the default using the
 241  GITWEB_CONFIG_SYSTEM build configuration variable, and override it
 242  through the GITWEB_CONFIG_SYSTEM environment variable.
 243
 244- The gitweb config file is a fragment of perl code. You can set variables
 245  using "our $variable = value"; text from "#" character until the end
 246  of a line is ignored. See perlsyn(1) for details.
 247
 248  See the top of gitweb.perl file for examples of customizable options.
 249
 250Config file example
 251~~~~~~~~~~~~~~~~~~~
 252
 253To enable blame, pickaxe search, and snapshot support, while allowing
 254individual projects to turn them off, put the following in your
 255GITWEB_CONFIG file:
 256
 257        $feature{'blame'}{'default'} = [1];
 258        $feature{'blame'}{'override'} = 1;
 259
 260        $feature{'pickaxe'}{'default'} = [1];
 261        $feature{'pickaxe'}{'override'} = 1;
 262
 263        $feature{'snapshot'}{'default'} = ['zip', 'tgz'];
 264        $feature{'snapshot'}{'override'} = 1;
 265
 266If you allow overriding for the snapshot feature, you can specify which
 267snapshot formats are globally disabled. You can also add any command line
 268options you want (such as setting the compression level). For instance,
 269you can disable Zip compressed snapshots and set GZip to run at level 6 by
 270adding the following lines to your $GITWEB_CONFIG:
 271
 272        $known_snapshot_formats{'zip'}{'disabled'} = 1;
 273        $known_snapshot_formats{'tgz'}{'compressor'} = ['gzip','-6'];
 274
 275
 276Gitweb repositories
 277-------------------
 278
 279- By default all git repositories under projectroot are visible and
 280  available to gitweb. The list of projects is generated by default by
 281  scanning the projectroot directory for git repositories (for object
 282  databases to be more exact).
 283
 284  You can provide a pre-generated list of [visible] repositories,
 285  together with information about their owners (the project ownership
 286  defaults to the owner of the repository directory otherwise), by setting
 287  the GITWEB_LIST build configuration variable (or the $projects_list
 288  variable in the gitweb config file) to point to a plain file.
 289
 290  Each line of the projects list file should consist of the url-encoded path
 291  to the project repository database (relative to projectroot), followed
 292  by the url-encoded project owner on the same line (separated by a space).
 293  Spaces in both project path and project owner have to be encoded as either
 294  '%20' or '+'.
 295
 296  Other characters that have to be url-encoded, i.e. replaced by '%'
 297  followed by two-digit character number in octal, are: other whitespace
 298  characters (because they are field separator in a record), plus sign '+'
 299  (because it can be used as replacement for spaces), and percent sign '%'
 300  (which is used for encoding / escaping).
 301
 302  You can generate the projects list index file using the project_index
 303  action (the 'TXT' link on projects list page) directly from gitweb.
 304
 305- By default, even if a project is not visible on projects list page, you
 306  can view it nevertheless by hand-crafting a gitweb URL. You can set the
 307  GITWEB_STRICT_EXPORT build configuration variable (or the $strict_export
 308  variable in the gitweb config file) to only allow viewing of
 309  repositories also shown on the overview page.
 310
 311- Alternatively, you can configure gitweb to only list and allow
 312  viewing of the explicitly exported repositories, via the
 313  GITWEB_EXPORT_OK build configuration variable (or the $export_ok
 314  variable in gitweb config file). If it evaluates to true, gitweb
 315  shows repositories only if this file exists in its object database
 316  (if directory has the magic file named $export_ok).
 317
 318- Finally, it is possible to specify an arbitrary perl subroutine that
 319  will be called for each project to determine if it can be exported.
 320  The subroutine receives an absolute path to the project as its only
 321  parameter.
 322
 323  For example, if you use mod_perl to run the script, and have dumb
 324  http protocol authentication configured for your repositories, you
 325  can use the following hook to allow access only if the user is
 326  authorized to read the files:
 327
 328    $export_auth_hook = sub {
 329        use Apache2::SubRequest ();
 330        use Apache2::Const -compile => qw(HTTP_OK);
 331        my $path = "$_[0]/HEAD";
 332        my $r    = Apache2::RequestUtil->request;
 333        my $sub  = $r->lookup_file($path);
 334        return $sub->filename eq $path
 335            && $sub->status == Apache2::Const::HTTP_OK;
 336    };
 337
 338
 339Generating projects list using gitweb
 340~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 341
 342We assume that GITWEB_CONFIG has its default Makefile value, namely
 343gitweb_config.perl. Put the following in gitweb_make_index.perl file:
 344
 345        $GITWEB_CONFIG = "gitweb_config.perl";
 346        do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
 347
 348        $projects_list = $projectroot;
 349
 350Then create the following script to get list of project in the format
 351suitable for GITWEB_LIST build configuration variable (or
 352$projects_list variable in gitweb config):
 353
 354        #!/bin/sh
 355
 356        export GITWEB_CONFIG="gitweb_make_index.perl"
 357        export GATEWAY_INTERFACE="CGI/1.1"
 358        export HTTP_ACCEPT="*/*"
 359        export REQUEST_METHOD="GET"
 360        export QUERY_STRING="a=project_index"
 361
 362        perl -- /var/www/cgi-bin/gitweb.cgi
 363
 364
 365Example web server configuration
 366~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 367
 368See also "Webserver configuration" section in README file for gitweb
 369(in gitweb/README).
 370
 371
 372- Apache2, gitweb installed as CGI script,
 373  under /var/www/cgi-bin/
 374
 375        ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
 376
 377        <Directory "/var/www/cgi-bin">
 378            Options Indexes FollowSymlinks ExecCGI
 379            AllowOverride None
 380            Order allow,deny
 381            Allow from all
 382        </Directory>
 383
 384- Apache2, gitweb installed as mod_perl legacy script,
 385  under /var/www/perl/
 386
 387        Alias /perl "/var/www/perl"
 388
 389        <Directory "/var/www/perl">
 390            SetHandler perl-script
 391            PerlResponseHandler ModPerl::Registry
 392            PerlOptions +ParseHeaders
 393            Options Indexes FollowSymlinks +ExecCGI
 394            AllowOverride None
 395            Order allow,deny
 396            Allow from all
 397        </Directory>