gitweb / INSTALLon commit Merge branch 'en/merge-recursive-2' (96b7c4d)
   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 per-instance 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  Note that if per-instance configuration file exists, then system-wide
 245  configuration is _not used at all_.  This is quite untypical and suprising
 246  behavior.  On the other hand changing current behavior would break backwards
 247  compatibility and can lead to unexpected changes in gitweb behavior.
 248  Therefore gitweb also looks for common system-wide configuration file,
 249  normally /etc/gitweb-common.conf (set during build time using build time
 250  configuration variable GITWEB_CONFIG_COMMON, set it at runtime using
 251  environment variable with the same name).  Settings from per-instance or
 252  system-wide configuration file override those from common system-wide
 253  configuration file.
 254
 255- The gitweb config file is a fragment of perl code. You can set variables
 256  using "our $variable = value"; text from "#" character until the end
 257  of a line is ignored. See perlsyn(1) for details.
 258
 259  See the top of gitweb.perl file for examples of customizable options.
 260
 261Config file example
 262~~~~~~~~~~~~~~~~~~~
 263
 264To enable blame, pickaxe search, and snapshot support, while allowing
 265individual projects to turn them off, put the following in your
 266GITWEB_CONFIG file:
 267
 268        $feature{'blame'}{'default'} = [1];
 269        $feature{'blame'}{'override'} = 1;
 270
 271        $feature{'pickaxe'}{'default'} = [1];
 272        $feature{'pickaxe'}{'override'} = 1;
 273
 274        $feature{'snapshot'}{'default'} = ['zip', 'tgz'];
 275        $feature{'snapshot'}{'override'} = 1;
 276
 277If you allow overriding for the snapshot feature, you can specify which
 278snapshot formats are globally disabled. You can also add any command line
 279options you want (such as setting the compression level). For instance,
 280you can disable Zip compressed snapshots and set GZip to run at level 6 by
 281adding the following lines to your $GITWEB_CONFIG:
 282
 283        $known_snapshot_formats{'zip'}{'disabled'} = 1;
 284        $known_snapshot_formats{'tgz'}{'compressor'} = ['gzip','-6'];
 285
 286
 287Gitweb repositories
 288-------------------
 289
 290- By default all git repositories under projectroot are visible and
 291  available to gitweb. The list of projects is generated by default by
 292  scanning the projectroot directory for git repositories (for object
 293  databases to be more exact).
 294
 295  You can provide a pre-generated list of [visible] repositories,
 296  together with information about their owners (the project ownership
 297  defaults to the owner of the repository directory otherwise), by setting
 298  the GITWEB_LIST build configuration variable (or the $projects_list
 299  variable in the gitweb config file) to point to a plain file.
 300
 301  Each line of the projects list file should consist of the url-encoded path
 302  to the project repository database (relative to projectroot), followed
 303  by the url-encoded project owner on the same line (separated by a space).
 304  Spaces in both project path and project owner have to be encoded as either
 305  '%20' or '+'.
 306
 307  Other characters that have to be url-encoded, i.e. replaced by '%'
 308  followed by two-digit character number in octal, are: other whitespace
 309  characters (because they are field separator in a record), plus sign '+'
 310  (because it can be used as replacement for spaces), and percent sign '%'
 311  (which is used for encoding / escaping).
 312
 313  You can generate the projects list index file using the project_index
 314  action (the 'TXT' link on projects list page) directly from gitweb.
 315
 316- By default, even if a project is not visible on projects list page, you
 317  can view it nevertheless by hand-crafting a gitweb URL. You can set the
 318  GITWEB_STRICT_EXPORT build configuration variable (or the $strict_export
 319  variable in the gitweb config file) to only allow viewing of
 320  repositories also shown on the overview page.
 321
 322- Alternatively, you can configure gitweb to only list and allow
 323  viewing of the explicitly exported repositories, via the
 324  GITWEB_EXPORT_OK build configuration variable (or the $export_ok
 325  variable in gitweb config file). If it evaluates to true, gitweb
 326  shows repositories only if this file exists in its object database
 327  (if directory has the magic file named $export_ok).
 328
 329- Finally, it is possible to specify an arbitrary perl subroutine that
 330  will be called for each project to determine if it can be exported.
 331  The subroutine receives an absolute path to the project as its only
 332  parameter.
 333
 334  For example, if you use mod_perl to run the script, and have dumb
 335  http protocol authentication configured for your repositories, you
 336  can use the following hook to allow access only if the user is
 337  authorized to read the files:
 338
 339    $export_auth_hook = sub {
 340        use Apache2::SubRequest ();
 341        use Apache2::Const -compile => qw(HTTP_OK);
 342        my $path = "$_[0]/HEAD";
 343        my $r    = Apache2::RequestUtil->request;
 344        my $sub  = $r->lookup_file($path);
 345        return $sub->filename eq $path
 346            && $sub->status == Apache2::Const::HTTP_OK;
 347    };
 348
 349
 350Generating projects list using gitweb
 351~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 352
 353We assume that GITWEB_CONFIG has its default Makefile value, namely
 354gitweb_config.perl. Put the following in gitweb_make_index.perl file:
 355
 356        $GITWEB_CONFIG = "gitweb_config.perl";
 357        do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
 358
 359        $projects_list = $projectroot;
 360
 361Then create the following script to get list of project in the format
 362suitable for GITWEB_LIST build configuration variable (or
 363$projects_list variable in gitweb config):
 364
 365        #!/bin/sh
 366
 367        export GITWEB_CONFIG="gitweb_make_index.perl"
 368        export GATEWAY_INTERFACE="CGI/1.1"
 369        export HTTP_ACCEPT="*/*"
 370        export REQUEST_METHOD="GET"
 371        export QUERY_STRING="a=project_index"
 372
 373        perl -- /var/www/cgi-bin/gitweb.cgi
 374
 375
 376Example web server configuration
 377~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 378
 379See also "Webserver configuration" section in README file for gitweb
 380(in gitweb/README).
 381
 382
 383- Apache2, gitweb installed as CGI script,
 384  under /var/www/cgi-bin/
 385
 386        ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
 387
 388        <Directory "/var/www/cgi-bin">
 389            Options Indexes FollowSymlinks ExecCGI
 390            AllowOverride None
 391            Order allow,deny
 392            Allow from all
 393        </Directory>
 394
 395- Apache2, gitweb installed as mod_perl legacy script,
 396  under /var/www/perl/
 397
 398        Alias /perl "/var/www/perl"
 399
 400        <Directory "/var/www/perl">
 401            SetHandler perl-script
 402            PerlResponseHandler ModPerl::Registry
 403            PerlOptions +ParseHeaders
 404            Options Indexes FollowSymlinks +ExecCGI
 405            AllowOverride None
 406            Order allow,deny
 407            Allow from all
 408        </Directory>