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