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