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