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