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