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
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
33 - Perl modules: CGI, Encode, Fcntl, File::Find, File::Basename.
36 The 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
43 Build time configuration
44 ------------------------
46 See also "How to configure gitweb for your local system" section below.
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.
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)
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.
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
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
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.
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.
91 How to configure gitweb for your local system
92 ---------------------------------------------
94 You can specify the following configuration variables when building GIT:
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)]
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]
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]
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]
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]
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]
134 Filename of html text to include at top of each page. Relative to
135 gitweb.cgi script. [No default]
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>.
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]
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]
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
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
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]
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]
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]
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]
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.
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
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 \
225 make gitwebdir=/var/www/cgi-bin/gitweb install-gitweb
231 See also "Runtime gitweb configuration" section in README file
232 for gitweb (in gitweb/README).
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.
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
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.
259 See the top of gitweb.perl file for examples of customizable options.
264 To enable blame, pickaxe search, and snapshot support, while allowing
265 individual projects to turn them off, put the following in your
268 $feature{'blame'}{'default'} = [1];
269 $feature{'blame'}{'override'} = 1;
271 $feature{'pickaxe'}{'default'} = [1];
272 $feature{'pickaxe'}{'override'} = 1;
274 $feature{'snapshot'}{'default'} = ['zip', 'tgz'];
275 $feature{'snapshot'}{'override'} = 1;
277 If you allow overriding for the snapshot feature, you can specify which
278 snapshot formats are globally disabled. You can also add any command line
279 options you want (such as setting the compression level). For instance,
280 you can disable Zip compressed snapshots and set GZip to run at level 6 by
281 adding the following lines to your $GITWEB_CONFIG:
283 $known_snapshot_formats{'zip'}{'disabled'} = 1;
284 $known_snapshot_formats{'tgz'}{'compressor'} = ['gzip','-6'];
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).
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.
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
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).
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.
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.
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).
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
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:
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;
350 Generating projects list using gitweb
351 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
353 We assume that GITWEB_CONFIG has its default Makefile value, namely
354 gitweb_config.perl. Put the following in gitweb_make_index.perl file:
356 $GITWEB_CONFIG = "gitweb_config.perl";
357 do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
359 $projects_list = $projectroot;
361 Then create the following script to get list of project in the format
362 suitable for GITWEB_LIST build configuration variable (or
363 $projects_list variable in gitweb config):
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"
373 perl -- /var/www/cgi-bin/gitweb.cgi
376 Example web server configuration
377 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
379 See also "Webserver configuration" section in README file for gitweb
383 - Apache2, gitweb installed as CGI script,
384 under /var/www/cgi-bin/
386 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
388 <Directory "/var/www/cgi-bin">
389 Options Indexes FollowSymlinks ExecCGI
395 - Apache2, gitweb installed as mod_perl legacy script,
398 Alias /perl "/var/www/perl"
400 <Directory "/var/www/perl">
401 SetHandler perl-script
402 PerlResponseHandler ModPerl::Registry
403 PerlOptions +ParseHeaders
404 Options Indexes FollowSymlinks +ExecCGI