]>
Commit | Line | Data |
---|---|---|
0a8f4f00 | 1 | GIT web Interface |
128eead1 | 2 | ================= |
0a8f4f00 JH |
3 | |
4 | The one working on: | |
eae7a759 | 5 | http://git.kernel.org/ |
0a8f4f00 | 6 | |
175fb6c0 | 7 | From the git version 1.4.0 gitweb is bundled with git. |
0a8f4f00 | 8 | |
5d043a3d | 9 | |
128eead1 MW |
10 | How to configure gitweb for your local system |
11 | --------------------------------------------- | |
5d043a3d | 12 | |
eae7a759 | 13 | See also the "Build time configuration" section in the INSTALL |
61fd2552 JN |
14 | file for gitweb (in gitweb/INSTALL). |
15 | ||
5d043a3d | 16 | You can specify the following configuration variables when building GIT: |
61fd2552 | 17 | * GIT_BINDIR |
eae7a759 RGS |
18 | Points where to find the git executable. You should set it up to |
19 | the place where the git binary was installed (usually /usr/bin) if you | |
61fd2552 | 20 | don't install git from sources together with gitweb. [Default: $(bindir)] |
5d043a3d | 21 | * GITWEB_SITENAME |
61fd2552 JN |
22 | Shown in the title of all generated pages, defaults to the server name |
23 | (SERVER_NAME CGI environment variable) if not set. [No default] | |
5d043a3d | 24 | * GITWEB_PROJECTROOT |
61fd2552 JN |
25 | The root directory for all projects shown by gitweb. Must be set |
26 | correctly for gitweb to find repositories to display. See also | |
eae7a759 | 27 | "Gitweb repositories" in the INSTALL file for gitweb. [Default: /pub/git] |
61fd2552 | 28 | * GITWEB_PROJECT_MAXDEPTH |
eae7a759 | 29 | The filesystem traversing limit for getting the project list; the number |
61fd2552 JN |
30 | is taken as depth relative to the projectroot. It is used when |
31 | GITWEB_LIST is a directory (or is not set; then project root is used). | |
32 | Is is meant to speed up project listing on large work trees by limiting | |
eae7a759 | 33 | search depth. [Default: 2007] |
5d043a3d | 34 | * GITWEB_LIST |
61fd2552 JN |
35 | Points to a directory to scan for projects (defaults to project root |
36 | if not set / if empty) or to a file with explicit listing of projects | |
37 | (together with projects' ownership). See "Generating projects list | |
38 | using gitweb" in INSTALL file for gitweb to find out how to generate | |
39 | such file from scan of a directory. [No default, which means use root | |
40 | directory for projects] | |
41 | * GITWEB_EXPORT_OK | |
42 | Show repository only if this file exists (in repository). Only | |
43 | effective if this variable evaluates to true. [No default / Not set] | |
44 | * GITWEB_STRICT_EXPORT | |
45 | Only allow viewing of repositories also shown on the overview page. | |
46 | This for example makes GITWEB_EXPORT_OK to decide if repository is | |
47 | available and not only if it is shown. If GITWEB_LIST points to | |
48 | file with list of project, only those repositories listed would be | |
49 | available for gitweb. [No default] | |
5d043a3d | 50 | * GITWEB_HOMETEXT |
61fd2552 JN |
51 | Points to an .html file which is included on the gitweb project |
52 | overview page ('projects_list' view), if it exists. Relative to | |
53 | gitweb.cgi script. [Default: indextext.html] | |
54 | * GITWEB_SITE_HEADER | |
55 | Filename of html text to include at top of each page. Relative to | |
56 | gitweb.cgi script. [No default] | |
57 | * GITWEB_SITE_FOOTER | |
58 | Filename of html text to include at bottom of each page. Relative to | |
59 | gitweb.cgi script. [No default] | |
60 | * GITWEB_HOME_LINK_STR | |
61 | String of the home link on top of all pages, leading to $home_link | |
62 | (usually main gitweb page, which means projects list). Used as first | |
63 | part of gitweb view "breadcrumb trail": <home> / <project> / <view>. | |
64 | [Default: projects] | |
65 | * GITWEB_SITENAME | |
66 | Name of your site or organization to appear in page titles. Set it | |
67 | to something descriptive for clearer bookmarks etc. If not set | |
68 | (if empty) gitweb uses "$SERVER_NAME Git", or "Untitled Git" if | |
69 | SERVER_NAME CGI environment variable is not set (e.g. if running | |
70 | gitweb as standalone script). [No default] | |
71 | * GITWEB_BASE_URL | |
72 | Git base URLs used for URL to where fetch project from, i.e. full | |
73 | URL is "$git_base_url/$project". Shown on projects summary page. | |
74 | Repository URL for project can be also configured per repository; this | |
eae7a759 | 75 | takes precedence over URLs composed from base URL and a project name. |
61fd2552 | 76 | Note that you can setup multiple base URLs (for example one for |
eae7a759 RGS |
77 | git:// protocol access, another for http:// access) from the gitweb |
78 | config file. [No default] | |
5d043a3d | 79 | * GITWEB_CSS |
61fd2552 | 80 | Points to the location where you put gitweb.css on your web server |
eae7a759 RGS |
81 | (or to be more generic, the URI of gitweb stylesheet). Relative to the |
82 | base URI of gitweb. Note that you can setup multiple stylesheets from | |
18d05328 PKS |
83 | the gitweb config file. [Default: static/gitweb.css (or |
84 | static/gitweb.min.css if the CSSMIN variable is defined / CSS minifier | |
85 | is used)] | |
281f2f6b | 86 | * GITWEB_LOGO |
61fd2552 JN |
87 | Points to the location where you put git-logo.png on your web server |
88 | (or to be more generic URI of logo, 72x27 size, displayed in top right | |
89 | corner of each gitweb page, and used as logo for Atom feed). Relative | |
18d05328 | 90 | to base URI of gitweb. [Default: static/git-logo.png] |
61fd2552 JN |
91 | * GITWEB_FAVICON |
92 | Points to the location where you put git-favicon.png on your web server | |
93 | (or to be more generic URI of favicon, assumed to be image/png type; | |
94 | web browsers that support favicons (website icons) may display them | |
95 | in the browser's URL bar and next to site name in bookmarks). Relative | |
18d05328 | 96 | to base URI of gitweb. [Default: static/git-favicon.png] |
4af819d4 | 97 | * GITWEB_JS |
22e5e58a | 98 | Points to the location where you put gitweb.js on your web server |
4af819d4 | 99 | (or to be more generic URI of JavaScript code used by gitweb). |
18d05328 PKS |
100 | Relative to base URI of gitweb. [Default: static/gitweb.js (or |
101 | static/gitweb.min.js if JSMIN build variable is defined / JavaScript | |
102 | minifier is used)] | |
bb55f77f | 103 | * GITWEB_CONFIG |
61fd2552 JN |
104 | This Perl file will be loaded using 'do' and can be used to override any |
105 | of the options above as well as some other options -- see the "Runtime | |
106 | gitweb configuration" section below, and top of 'gitweb.cgi' for their | |
107 | full list and description. If the environment variable GITWEB_CONFIG | |
108 | is set when gitweb.cgi is executed, then the file specified in the | |
109 | environment variable will be loaded instead of the file specified | |
110 | when gitweb.cgi was created. [Default: gitweb_config.perl] | |
17a8b250 GP |
111 | * GITWEB_CONFIG_SYSTEM |
112 | This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG | |
113 | does not exist. If the environment variable GITWEB_CONFIG_SYSTEM is set | |
114 | when gitweb.cgi is executed, then the file specified in the environment | |
115 | variable will be loaded instead of the file specified when gitweb.cgi was | |
116 | created. [Default: /etc/gitweb.conf] | |
5d043a3d | 117 | |
128eead1 | 118 | |
45a3b12c PB |
119 | Runtime gitweb configuration |
120 | ---------------------------- | |
121 | ||
122 | You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG` | |
17a8b250 GP |
123 | (defaults to 'gitweb_config.perl' in the same directory as the CGI), and |
124 | as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf). | |
45a3b12c | 125 | The most notable thing that is not configurable at compile time are the |
61fd2552 JN |
126 | optional features, stored in the '%features' variable. |
127 | ||
128 | Ultimate description on how to reconfigure the default features setting | |
129 | in your `GITWEB_CONFIG` or per-project in `project.git/config` can be found | |
130 | as comments inside 'gitweb.cgi'. | |
131 | ||
eae7a759 RGS |
132 | See also the "Gitweb config file" (with an example of config file), and |
133 | the "Gitweb repositories" sections in INSTALL file for gitweb. | |
61fd2552 JN |
134 | |
135 | ||
eae7a759 | 136 | The gitweb config file is a fragment of perl code. You can set variables |
61fd2552 JN |
137 | using "our $variable = value"; text from "#" character until the end |
138 | of a line is ignored. See perlsyn(1) man page for details. | |
139 | ||
eae7a759 | 140 | Below is the list of variables which you might want to set in gitweb config. |
61fd2552 JN |
141 | See the top of 'gitweb.cgi' for the full list of variables and their |
142 | descriptions. | |
143 | ||
144 | Gitweb config file variables | |
145 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
146 | ||
d661146a JN |
147 | You can set, among others, the following variables in gitweb config files |
148 | (with the exception of $projectroot and $projects_list this list does | |
149 | not include variables usually directly set during build): | |
61fd2552 | 150 | * $GIT |
eae7a759 | 151 | Core git executable to use. By default set to "$GIT_BINDIR/git", which |
61fd2552 JN |
152 | in turn is by default set to "$(bindir)/git". If you use git from binary |
153 | package, set this to "/usr/bin/git". This can just be "git" if your | |
154 | webserver has a sensible PATH. If you have multiple git versions | |
d661146a | 155 | installed it can be used to choose which one to use. |
61fd2552 JN |
156 | * $version |
157 | Gitweb version, set automatically when creating gitweb.cgi from | |
158 | gitweb.perl. You might want to modify it if you are running modified | |
159 | gitweb. | |
d661146a JN |
160 | * $projectroot |
161 | Absolute filesystem path which will be prepended to project path; | |
162 | the path to repository is $projectroot/$project. Set to | |
163 | $GITWEB_PROJECTROOT during installation. This variable have to be | |
164 | set correctly for gitweb to find repositories. | |
165 | * $projects_list | |
166 | Source of projects list, either directory to scan, or text file | |
e67c9e39 JN |
167 | with list of repositories (in the "<URI-encoded repository path> SP |
168 | <URI-encoded repository owner>" line format; actually there can be | |
169 | any sequence of whitespace in place of space (SP)). Set to | |
170 | $GITWEB_LIST during installation. If empty, $projectroot is used | |
171 | to scan for repositories. | |
61fd2552 | 172 | * $my_url, $my_uri |
e80f97e2 JN |
173 | Full URL and absolute URL of gitweb script; |
174 | in earlier versions of gitweb you might have need to set those | |
175 | variables, now there should be no need to do it. | |
46068383 JN |
176 | * $base_url |
177 | Base URL for relative URLs in pages generated by gitweb, | |
178 | (e.g. $logo, $favicon, @stylesheets if they are relative URLs), | |
179 | needed and used only for URLs with nonempty PATH_INFO via | |
b62a1a98 | 180 | <base href="$base_url">. Usually gitweb sets its value correctly, |
46068383 | 181 | and there is no need to set this variable, e.g. to $my_uri or "/". |
61fd2552 JN |
182 | * $home_link |
183 | Target of the home link on top of all pages (the first part of view | |
e80f97e2 | 184 | "breadcrumbs"). By default set to absolute URI of a page ($my_uri). |
61fd2552 JN |
185 | * @stylesheets |
186 | List of URIs of stylesheets (relative to base URI of a page). You | |
187 | might specify more than one stylesheet, for example use gitweb.css | |
188 | as base, with site specific modifications in separate stylesheet | |
189 | to make it easier to upgrade gitweb. You can add 'site' stylesheet | |
190 | for example by using | |
191 | push @stylesheets, "gitweb-site.css"; | |
eae7a759 | 192 | in the gitweb config file. |
61fd2552 JN |
193 | * $logo_url, $logo_label |
194 | URI and label (title) of GIT logo link (or your site logo, if you choose | |
195 | to use different logo image). By default they point to git homepage; | |
196 | in the past they pointed to git documentation at www.kernel.org. | |
197 | * $projects_list_description_width | |
198 | The width (in characters) of the projects list "Description" column. | |
199 | Longer descriptions will be cut (trying to cut at word boundary); | |
200 | full description is available as 'title' attribute (usually shown on | |
201 | mouseover). By default set to 25, which might be too small if you | |
202 | use long project descriptions. | |
203 | * @git_base_url_list | |
204 | List of git base URLs used for URL to where fetch project from, shown | |
205 | in project summary page. Full URL is "$git_base_url/$project". | |
206 | You can setup multiple base URLs (for example one for git:// protocol | |
207 | access, and one for http:// "dumb" protocol access). Note that per | |
208 | repository configuration in 'cloneurl' file, or as values of gitweb.url | |
209 | project config. | |
210 | * $default_blob_plain_mimetype | |
211 | Default mimetype for blob_plain (raw) view, if mimetype checking | |
212 | doesn't result in some other type; by default 'text/plain'. | |
213 | * $default_text_plain_charset | |
eae7a759 | 214 | Default charset for text files. If not set, web server configuration |
61fd2552 JN |
215 | would be used. |
216 | * $mimetypes_file | |
217 | File to use for (filename extension based) guessing of MIME types before | |
eae7a759 RGS |
218 | trying /etc/mime.types. Path, if relative, is taken currently as |
219 | relative to the current git repository. | |
61fd2552 JN |
220 | * $fallback_encoding |
221 | Gitweb assumes this charset if line contains non-UTF-8 characters. | |
222 | Fallback decoding is used without error checking, so it can be even | |
680ebc01 | 223 | 'utf-8'. Value must be valid encoding; see Encoding::Supported(3pm) man |
61fd2552 JN |
224 | page for a list. By default 'latin1', aka. 'iso-8859-1'. |
225 | * @diff_opts | |
226 | Rename detection options for git-diff and git-diff-tree. By default | |
227 | ('-M'); set it to ('-C') or ('-C', '-C') to also detect copies, or | |
228 | set it to () if you don't want to have renames detection. | |
7e1100e9 MM |
229 | * $prevent_xss |
230 | If true, some gitweb features are disabled to prevent content in | |
231 | repositories from launching cross-site scripting (XSS) attacks. Set this | |
232 | to true if you don't trust the content of your repositories. The default | |
233 | is false. | |
b62a1a98 JWH |
234 | * $maxload |
235 | Used to set the maximum load that we will still respond to gitweb queries. | |
22e5e58a | 236 | If server load exceed this value then return "503 Service Unavailable" error. |
b62a1a98 JWH |
237 | Server load is taken to be 0 if gitweb cannot determine its value. Set it to |
238 | undefined value to turn it off. The default is 300. | |
61fd2552 | 239 | |
e67c9e39 JN |
240 | |
241 | Projects list file format | |
242 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
243 | ||
244 | Instead of having gitweb find repositories by scanning filesystem starting | |
245 | from $projectroot (or $projects_list, if it points to directory), you can | |
246 | provide list of projects by setting $projects_list to a text file with list | |
247 | of projects (and some additional info). This file uses the following | |
248 | format: | |
249 | ||
250 | One record (for project / repository) per line, whitespace separated fields; | |
251 | does not support (at least for now) lines continuation (newline escaping). | |
252 | Leading and trailing whitespace are ignored, any run of whitespace can be | |
253 | used as field separator (rules for Perl's "split(' ', $line)"). Keyed by | |
254 | the first field, which is project name, i.e. path to repository GIT_DIR | |
255 | relative to $projectroot. Fields use modified URI encoding, defined in | |
256 | RFC 3986, section 2.1 (Percent-Encoding), or rather "Query string encoding" | |
257 | (see http://en.wikipedia.org/wiki/Query_string#URL_encoding), the difference | |
258 | being that SP (' ') can be encoded as '+' (and therefore '+' has to be also | |
259 | percent-encoded). Reserved characters are: '%' (used for encoding), '+' | |
260 | (can be used to encode SPACE), all whitespace characters as defined in Perl, | |
261 | including SP, TAB and LF, (used to separate fields in a record). | |
262 | ||
263 | Currently list of fields is | |
264 | * <repository path> - path to repository GIT_DIR, relative to $projectroot | |
265 | * <repository owner> - displayed as repository owner, preferably full name, | |
266 | or email, or both | |
267 | ||
268 | You can additionally use $projects_list file to limit which repositories | |
269 | are visible, and together with $strict_export to limit access to | |
270 | repositories (see "Gitweb repositories" section in gitweb/INSTALL). | |
271 | ||
272 | ||
61fd2552 JN |
273 | Per-repository gitweb configuration |
274 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
275 | ||
276 | You can also configure individual repositories shown in gitweb by creating | |
277 | file in the GIT_DIR of git repository, or by setting some repo configuration | |
278 | variable (in GIT_DIR/config). | |
279 | ||
280 | You can use the following files in repository: | |
281 | * README.html | |
282 | A .html file (HTML fragment) which is included on the gitweb project | |
283 | summary page inside <div> block element. You can use it for longer | |
e67c9e39 | 284 | description of a project, to provide links (for example to project's |
7e1100e9 MM |
285 | homepage), etc. This is recognized only if XSS prevention is off |
286 | ($prevent_xss is false); a way to include a readme safely when XSS | |
287 | prevention is on may be worked out in the future. | |
61fd2552 JN |
288 | * description (or gitweb.description) |
289 | Short (shortened by default to 25 characters in the projects list page) | |
290 | single line description of a project (of a repository). Plain text file; | |
291 | HTML will be escaped. By default set to | |
292 | Unnamed repository; edit this file to name it for gitweb. | |
eae7a759 | 293 | from the template during repository creation. You can use the |
61fd2552 | 294 | gitweb.description repo configuration variable, but the file takes |
eae7a759 | 295 | precedence. |
61fd2552 JN |
296 | * cloneurl (or multiple-valued gitweb.url) |
297 | File with repository URL (used for clone and fetch), one per line. | |
298 | Displayed in the project summary page. You can use multiple-valued | |
299 | gitweb.url repository configuration variable for that, but the file | |
eae7a759 | 300 | takes precedence. |
b59012ef BR |
301 | * gitweb.owner |
302 | You can use the gitweb.owner repository configuration variable to set | |
303 | repository's owner. It is displayed in the project list and summary | |
ef115e26 JN |
304 | page. If it's not set, filesystem directory's owner is used |
305 | (via GECOS field / real name field from getpwiud(3)). | |
61fd2552 JN |
306 | * various gitweb.* config variables (in config) |
307 | Read description of %feature hash for detailed list, and some | |
308 | descriptions. | |
45a3b12c PB |
309 | |
310 | ||
128eead1 MW |
311 | Webserver configuration |
312 | ----------------------- | |
313 | ||
314 | If you want to have one URL for both gitweb and your http:// | |
315 | repositories, you can configure apache like this: | |
316 | ||
55f409a8 | 317 | <VirtualHost *:80> |
964ad928 SR |
318 | ServerName git.example.org |
319 | DocumentRoot /pub/git | |
320 | SetEnv GITWEB_CONFIG /etc/gitweb.conf | |
321 | ||
322 | # turning on mod rewrite | |
55f409a8 | 323 | RewriteEngine on |
964ad928 | 324 | |
55f409a8 ABH |
325 | # make the front page an internal rewrite to the gitweb script |
326 | RewriteRule ^/$ /cgi-bin/gitweb.cgi | |
964ad928 | 327 | |
55f409a8 ABH |
328 | # make access for "dumb clients" work |
329 | RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT] | |
128eead1 MW |
330 | </VirtualHost> |
331 | ||
332 | The above configuration expects your public repositories to live under | |
333 | /pub/git and will serve them as http://git.domain.org/dir-under-pub-git, | |
334 | both as cloneable GIT URL and as browseable gitweb interface. | |
335 | If you then start your git-daemon with --base-path=/pub/git --export-all | |
336 | then you can even use the git:// URL with exactly the same path. | |
337 | ||
604cb211 AC |
338 | Setting the environment variable GITWEB_CONFIG will tell gitweb to use |
339 | the named file (i.e. in this example /etc/gitweb.conf) as a | |
340 | configuration for gitweb. Perl variables defined in here will | |
341 | override the defaults given at the head of the gitweb.perl (or | |
342 | gitweb.cgi). Look at the comments in that file for information on | |
343 | which variables and what they mean. | |
128eead1 | 344 | |
55f409a8 ABH |
345 | If you use the rewrite rules from the example you'll likely also need |
346 | something like the following in your gitweb.conf (or gitweb_config.perl) file: | |
347 | ||
348 | @stylesheets = ("/some/absolute/path/gitweb.css"); | |
349 | $my_uri = "/"; | |
350 | $home_link = "/"; | |
351 | ||
128eead1 | 352 | |
964ad928 SR |
353 | Webserver configuration with multiple projects' root |
354 | ---------------------------------------------------- | |
355 | ||
356 | If you want to use gitweb with several project roots you can edit your apache | |
357 | virtual host and gitweb.conf configuration files like this : | |
358 | ||
359 | virtual host configuration : | |
360 | ||
361 | <VirtualHost *:80> | |
362 | ServerName git.example.org | |
363 | DocumentRoot /pub/git | |
364 | SetEnv GITWEB_CONFIG /etc/gitweb.conf | |
365 | ||
366 | # turning on mod rewrite | |
367 | RewriteEngine on | |
368 | ||
369 | # make the front page an internal rewrite to the gitweb script | |
370 | RewriteRule ^/$ /cgi-bin/gitweb.cgi [QSA,L,PT] | |
371 | ||
372 | # look for a public_git folder in unix users' home | |
373 | # http://git.example.org/~<user>/ | |
374 | RewriteRule ^/\~([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT] | |
375 | ||
376 | # http://git.example.org/+<user>/ | |
377 | #RewriteRule ^/\+([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT] | |
378 | ||
379 | # http://git.example.org/user/<user>/ | |
380 | #RewriteRule ^/user/([^\/]+)/(gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT] | |
381 | ||
382 | # defined list of project roots | |
383 | RewriteRule ^/scm(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT] | |
384 | RewriteRule ^/var(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT] | |
385 | ||
386 | # make access for "dumb clients" work | |
387 | RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT] | |
388 | </VirtualHost> | |
389 | ||
390 | gitweb.conf configuration : | |
391 | ||
392 | $projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git"; | |
393 | ||
394 | These configurations enable two things. First, each unix user (<user>) of the | |
395 | server will be able to browse through gitweb git repositories found in | |
396 | ~/public_git/ with the following url : http://git.example.org/~<user>/ | |
397 | ||
398 | If you do not want this feature on your server just remove the second rewrite rule. | |
399 | ||
400 | If you already use mod_userdir in your virtual host or you don't want to use | |
401 | the '~' as first character just comment or remove the second rewrite rule and | |
402 | uncomment one of the following according to what you want. | |
403 | ||
404 | Second, repositories found in /pub/scm/ and /var/git/ will be accesible | |
405 | through http://git.example.org/scm/ and http://git.example.org/var/. | |
406 | You can add as many project roots as you want by adding rewrite rules like the | |
407 | third and the fourth. | |
408 | ||
409 | ||
0dbf027a GB |
410 | PATH_INFO usage |
411 | ----------------------- | |
412 | If you enable PATH_INFO usage in gitweb by putting | |
413 | ||
414 | $feature{'pathinfo'}{'default'} = [1]; | |
415 | ||
416 | in your gitweb.conf, it is possible to set up your server so that it | |
417 | consumes and produces URLs in the form | |
418 | ||
419 | http://git.example.com/project.git/shortlog/sometag | |
420 | ||
421 | by using a configuration such as the following, that assumes that | |
422 | /var/www/gitweb is the DocumentRoot of your webserver, and that it | |
423 | contains the gitweb.cgi script and complementary static files | |
424 | (stylesheet, favicon): | |
425 | ||
426 | <VirtualHost *:80> | |
427 | ServerAlias git.example.com | |
428 | ||
429 | DocumentRoot /var/www/gitweb | |
430 | ||
431 | <Directory /var/www/gitweb> | |
432 | Options ExecCGI | |
433 | AddHandler cgi-script cgi | |
434 | ||
435 | DirectoryIndex gitweb.cgi | |
436 | ||
437 | RewriteEngine On | |
438 | RewriteCond %{REQUEST_FILENAME} !-f | |
439 | RewriteCond %{REQUEST_FILENAME} !-d | |
440 | RewriteRule ^.* /gitweb.cgi/$0 [L,PT] | |
441 | </Directory> | |
442 | </VirtualHost> | |
443 | ||
444 | The rewrite rule guarantees that existing static files will be properly | |
445 | served, whereas any other URL will be passed to gitweb as PATH_INFO | |
446 | parameter. | |
447 | ||
448 | Notice that in this case you don't need special settings for | |
449 | @stylesheets, $my_uri and $home_link, but you lose "dumb client" access | |
450 | to your project .git dirs. A possible workaround for the latter is the | |
451 | following: in your project root dir (e.g. /pub/git) have the projects | |
452 | named without a .git extension (e.g. /pub/git/project instead of | |
453 | /pub/git/project.git) and configure Apache as follows: | |
454 | ||
455 | <VirtualHost *:80> | |
456 | ServerAlias git.example.com | |
457 | ||
458 | DocumentRoot /var/www/gitweb | |
459 | ||
1bed73c6 | 460 | AliasMatch ^(/.*?)(\.git)(/.*)?$ /pub/git$1$3 |
0dbf027a GB |
461 | <Directory /var/www/gitweb> |
462 | Options ExecCGI | |
463 | AddHandler cgi-script cgi | |
464 | ||
465 | DirectoryIndex gitweb.cgi | |
466 | ||
467 | RewriteEngine On | |
468 | RewriteCond %{REQUEST_FILENAME} !-f | |
469 | RewriteCond %{REQUEST_FILENAME} !-d | |
470 | RewriteRule ^.* /gitweb.cgi/$0 [L,PT] | |
471 | </Directory> | |
472 | </VirtualHost> | |
473 | ||
474 | The additional AliasMatch makes it so that | |
475 | ||
476 | http://git.example.com/project.git | |
477 | ||
478 | will give raw access to the project's git dir (so that the project can | |
479 | be cloned), while | |
480 | ||
481 | http://git.example.com/project | |
482 | ||
483 | will provide human-friendly gitweb access. | |
484 | ||
1bed73c6 GB |
485 | This solution is not 100% bulletproof, in the sense that if some project |
486 | has a named ref (branch, tag) starting with 'git/', then paths such as | |
487 | ||
488 | http://git.example.com/project/command/abranch..git/abranch | |
489 | ||
490 | will fail with a 404 error. | |
491 | ||
492 | ||
0dbf027a | 493 | |
ee0d3234 | 494 | Originally written by: |
0a8f4f00 | 495 | Kay Sievers <kay.sievers@vrfy.org> |
ee0d3234 JH |
496 | |
497 | Any comment/question/concern to: | |
498 | Git mailing list <git@vger.kernel.org> |