安装:yum -y install mod_ssl httpd mod_dav mod_dav_fs
git :
yum -y install gettext-devel expat-devel curl-devel zlib-devel openssl-devel gcc perl-devel
cd /usr/local/src
wget https://www.kernel.org/pub/software/scm/git/git-1.8.2.3.tar.gz
tar xzvf git-1.8.2.3.tar.gz
cd git-1.8.2.3
make prefix=/usr/local all
make prefix=/usr/local install
配置
[root@localhost git]# cat /etc/httpd/conf.d/git.conf
SetEnv GIT_PROJECT_ROOT /var/www/html/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git /usr/local/libexec/git-core/git-http-backend
<LocationMatch “^/git/test.git/.*$”>
Dav On
Options +Indexes +FollowSymLinks
AuthType Basic
AuthName “Git Access”
AuthType Basic
AuthName “Please login”
AuthBasicProvider ldap
AuthLDAPURL “ldap://192.168.7.1:389/ou=system-admin,ou=login,dc=test,dc=com”
AuthLDAPBindDN “cn=admin,dc=test,dc=com”
AuthLDAPBindPassword “test”
Require valid-user
</LocationMatch>
遇到的问题:
遇到一个奇怪的问题,搭建好git之后,很奇怪的问题。linux下提交无问题,但是windows 提交的时候一直报
git.exe push –progress “origin” master:master
git: ‘http-push’ is not a git command. See ‘git –help’.
fatal: git-http-push failed
后来从一篇文章发现:
新增一config档,并编辑它/etc/httpd/conf.d/git.conf ,让Apache知道GIT的Repository ROOT在哪? 哪个URI会要调用git-http-backend?
配置添加
SetEnv GIT_PROJECT_ROOT /opt/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
提交的时候就没有问题了。
而且 如果没有配置以上内容。需要执行git update-server-info 否则,clone会报错,
[Fri Oct 24 17:59:05 2014] [error] [client 192.168.0.151] File does not exist: /var/www/html/git/test.git/info/refs
但是如果配置以上内容的话,则无需配置也能clone。
参考: