Debian / Apache – build立一个没有虚拟主机的git服务器+ gitweb

我正在努力设置一个干净的,有gitweb的没有虚拟主机的 git服务器。

软件

初始设置

  • mod userdir激活
  • Apache DocumentRoot是/ home / user / public_html
  • php5-cgi和相关的Apache模块启用
  • 将“user”添加到www-data并添加了正确的权限

目标

  • 没有虚拟主机
  • 所有在/ home / user / git中的git回收站,
  • Repos clonable / pushable从http://myserver/git/myrepo.git (ssh,http,git)
  • Gitweb从http:// myserver / git (如果不可能, http:// myserver / gitweb )
  • .htpasswd保护

遵循资源

  • 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> 

现在http://myserver/git显示了回购列表,但http://myserver/git/repo.git/是“找不到”,gitweb无法访问。

通过apt-get安装gitweb后,你应该运行以下命令:

 # a2enmod cgi # service restart apache2 

然后inputhttp:// your-hostname / gitweb