I've just installed Git on my production server and am hoping to get GitWeb working with it. I became very interested in getting it to work when I stumbled across a tutorial showing how to make git web work using...
git instaweb -d webrick --start
It works exactly as described in the tutorial at ... http://lostechies.com/jasonmeridth/2009/09/27/git-instaweb/
However after reading other forums it seems like instaweb is not really meant to be used and instead I should set up GitWeb to run on Apache.
I am fairly new to Apache so am not very familiar with what I should be doing. I've been following the tutorial at http://unix-heaven.org/node/31 . But i don't think I need all of it. I think the only thing I need to do is put the following in my httpd.conf file...
<VirtualHost *:80>
ServerAdmin <a href="mailto:[email protected]">[email protected]</a>
ServerName git.example.org
ServerAlias git-pub.example.org
RedirectMatch ^/$ /gitweb.cgi
SetEnv GITWEB_PROJECTROOT /cvs/codeRepository/git
Alias /gitweb.js /srv/www/gitweb/static/gitweb.js
Alias /gitweb.css /srv/www/gitweb/static/gitweb.css
Alias /git-logo.png /srv/www/gitweb/static/git-logo.png
Alias /git-favicon.png /srv/www/gitweb/static/git-favicon.png
ScriptAlias / "/srv/www/gitweb/"
<Directory "/srv/www/gitweb/">
AllowOverride None
Options Indexes FollowSymLinks ExecCGI
Order allow,deny
Allow from all
</Directory>
ErrorLog "/var/log/apache2/httpd-git-pub.example.org-access.log"
CustomLog "/var/log/apache2/httpd-git-pub.example.org-error.log" common
</VirtualHost>
Where /srv/www/gitweb/ contains....
$:/srv/www/gitweb # ls -ltr
total 252
-rwx------ 1 root root 247917 Feb 27 15:02 gitweb.cgi
drwx------ 2 root root 4096 Feb 27 15:03 static
Will the config I've specified above work or I need to specify ? And if so what url will I access GitWeb at? Do I need serverName, serverAlias and serverAdmin?
Thanks for your help
The url you would use would be
http://git.example.org
But I am not so sure about your config. Mine is simpler, and I always recommend an address like http(s)://yourServer/gitweb, instead of just http(s)://yourServer/: if you need to add more services, you can add more root url (like /gitweb
).
For a quick http access without authentication:
# GitWeb on 80
Listen 80
<VirtualHost *:80>
ServerName git.example.org
ServerAlias git-pub.example.org
SetEnv GITWEB_PROJECTROOT /cvs/codeRepository/git
SetEnv GIT_HTTP_BACKEND "/usr/local/apps/git/libexec/git-core/git-http-backend"
DocumentRoot /srv/www/gitweb
Alias /gitweb /srv/www/gitweb
<Directory /srv/www/gitweb>
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
</Directory>
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
LogLevel Info
ErrorLog "/var/log/apache2/gitweb_error_log"
TransferLog "/var/log/apache2/gitweb_access_log"
</VirtualHost>
Note: in my original config file (which is a template, with placeholder values like @PORT_HTTP_GITWEB@
), I didn't use GITWEB_PROJECTROOT
because I am calling Gitolite, which knows where the Git repos are.
I do set a variable in the gitweb.conf
file, though, which plays the same role than GITWEB_PROJECTROOT
, according to the gitweb documentation:
$projectroot::
Absolute filesystem path which will be prepended to project path; the path to repository is
$projectroot/$project
.
Set to$GITWEB_PROJECTROOT
during installation.
This variable has to be set correctly for gitweb to find repositories.For example, if
$projectroot
is set to "/srv/git
" by putting the following in gitweb config file:
----------------------------------------------------------------------------
our $projectroot = "/srv/git";
----------------------------------------------------------------------------
then:
------------------------------------------------
http://git.example.com/gitweb.cgi?p=foo/bar.git
------------------------------------------------
and its path_info based equivalent
------------------------------------------------
http://git.example.com/gitweb.cgi/foo/bar.git
------------------------------------------------
will map to the path '/srv/git/foo/bar.git' on the filesystem.
Update August 2018, for Git 2.19 (Q3 2018, five years later)
"git instaweb
" has been adjusted to run better with newer Apache on RedHat based distros.
See commit 757b124 (07 Aug 2018), and commit 1976311 (08 Aug 2018) by Sebastian Kisela (skisela
).
(Merged by Junio C Hamano -- gitster
-- in commit 93ded33, 20 Aug 2018)
git-instaweb
: fix apache2 config with apache >= 2.4The generated apache2 config fails with apache >= 2.4. The error log states:
AH00136: Server MUST relinquish startup privileges before accepting connections. Please ensure mod_unixd or other system security module is loaded. AH00016: Configuration Failed
Fix this by loading the
unixd
module.
This works with olderhttpd
as well, so noIfVersion
conditional is needed. (Tested with httpd-2.2.15 on CentOS-6.)