I'm struggling to set up a clean and working git server with gitweb without virtualhost.
Software
- Debian 8
- Apache 2.4
Initial setup
- mod userdir activated
- Apache DocumentRoot is /home/user/public_html
- php5-cgi and related Apache modules enabled
- added "user" to www-data and added correct permissions
Goal
- No virtualhost
- All git repos in /home/user/git,
- Repos clonable/pushable from http://myserver/git/myrepo.git (ssh, http, git)
- Gitweb accessible from http://myserver/git (if not possible, http://myserver/gitweb)
- .htpasswd protected
Resources followed
- http://www.isi.edu/~gideon/gitweb.html
- http://www.tikalk.com/devops/setup-git-gitweb-git-http-backend-smart-http-ubuntu-1204/
/etc/apache2/sites-enabled/git.conf
Alias /git /home/user/git
<Directory /home/user/git>
Options All
AllowOverride All
Require all granted
Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf
RewriteEngine on
RewriteRule ^([^.]+\.git.*)$ /git/gitweb.cgi/$0 [L,PT]
</Directory>
ScriptAliasMatch \
"(?x)^/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
/usr/lib/git-core/git-http-backend/$1
SetEnv GIT_PROJECT_ROOT /home/user/git
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
/etc/apache2/conf-enabled/git.conf
<IfModule mod_alias.c>
<IfModule mod_cgi.c>
Define ENABLE_GITWEB
</IfModule>
<IfModule mod_cgid.c>
Define ENABLE_GITWEB
</IfModule>
</IfModule>
<IfDefine ENABLE_GITWEB>
Alias /git /usr/share/gitweb
<Directory /usr/share/gitweb>
Options +FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
</Directory>
</IfDefine>
Right now http://myserver/git
shows a list of repos, but http://myserver/git/repo.git/
is "not found" and gitweb is not accessible.
Best Answer
After installing gitweb via apt-get, you should run the following:
Then enter http://your-hostname/gitweb