July 28, 2011

git-http-backend on CentOS 5.5

from CentOS, Git & http-push unavailable

  • install new version curl in local directory
  • configure git as ./configure --with-curl=curl dir
apache settings from
  • git init --bare git-repo-dir (beware of the directory permission - httpd user writable)
  • git update-server-info
  • in /etc/httpd/conf/httpd.conf or /etc/httpd/conf.d/git.conf
SetEnv GIT_PROJECT_ROOT git-repo-dir
SetEnv GIT_HTTP_EXPORT_ALL
AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /git-repo-dir/$1
AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /git-repo-dir/$1
ScriptAliasMatch \
"(?x)^/git/(.*/(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/local/libexec/git-core/git-http-backend/$1
ScriptAlias /git/ /usr/local/share/gitweb/gitweb.cgi

<Directory "git-repo-dir">
Allow from all
</Directory>

<LocationMatch "/git">
AuthType Basic
AuthName "Git"
#AuthUserFile AuthFile
#Require valid-user

AuthBasicProvider ldap
AuthLDAPURL "ldap://server:389/dc=company,dc=local?sAMAccountName?sub?(objectclass=*)" NONE
AuthLDAPBindDN "cn=user,ou=team,ou=department,dc=company,dc=local"
AuthLDAPBindPassword secret

AuthzLDAPAuthoritative on
require ldap-user user1 user2 user3
</LocationMatch>

auth
  • git clone http://server/git-repo-dir
  • git clone http://username@server/git-repo-dir
  • git clone http://username:password@server/git-repo-dir
  • unset SSH_ASKPASS