我正在尝试build立一个基于git和git-http-backend和apache的仓库服务器。 我的问题? 我可以克隆完美,但是当我尝试推动,我打了一堵墙
$ git push origin master * Couldn't find host git.local in the .netrc file; using defaults * About to connect() to git.local port 80 (#0) * Trying 127.0.0.1... * connected * Connected to git.local (127.0.0.1) port 80 (#0) > GET /new/info/refs?service=git-receive-pack HTTP/1.1 User-Agent: git/1.7.1 Host: git.local Accept: */* Pragma: no-cache < HTTP/1.1 401 Authorization Required < Date: Tue, 23 Nov 2010 16:21:51 GMT < Server: Apache/2.2.16 (Ubuntu) < WWW-Authenticate: Basic realm="Private Git Access" < Vary: Accept-Encoding < Content-Length: 476 < Content-Type: text/html; charset=iso-8859-1 < * Ignoring the response-body * Connection #0 to host git.local left intact * Issue another request to this URL: 'http://shoaibi:[email protected]/new/info/refs?service=git-receive-pack' * Couldn't find host git.local in the .netrc file; using defaults * Re-using existing connection! (#0) with host git.local * Connected to git.local (127.0.0.1) port 80 (#0) * Server auth using Basic with user 'shoaibi' > GET /new/info/refs?service=git-receive-pack HTTP/1.1 Authorization: Basic c2hvYWliaTpzaG9haWJp User-Agent: git/1.7.1 Host: git.local Accept: */* Pragma: no-cache < HTTP/1.1 200 OK < Date: Tue, 23 Nov 2010 16:21:51 GMT < Server: Apache/2.2.16 (Ubuntu) < Last-Modified: Tue, 23 Nov 2010 15:30:17 GMT < ETag: "8853-0-495ba0cca2f10" < Accept-Ranges: bytes < Content-Length: 0 < Content-Type: text/plain < * Connection #0 to host git.local left intact * Couldn't find host git.local in the .netrc file; using defaults * Re-using existing connection! (#0) with host git.local * Connected to git.local (127.0.0.1) port 80 (#0) * Server auth using Basic with user 'shoaibi' > GET /new/HEAD HTTP/1.1 Authorization: Basic c2hvYWliaTpzaG9haWJp User-Agent: git/1.7.1 Host: git.local Accept: */* Pragma: no-cache < HTTP/1.1 200 OK < Date: Tue, 23 Nov 2010 16:21:51 GMT < Server: Apache/2.2.16 (Ubuntu) < Last-Modified: Tue, 23 Nov 2010 12:05:07 GMT < ETag: "88b7-17-495b72f0814f0" < Accept-Ranges: bytes < Content-Length: 23 < Content-Type: text/plain < * Expire cleared * Connection #0 to host git.local left intact * Couldn't find host git.local in the .netrc file; using defaults * About to connect() to git.local port 80 (#0) * Trying 127.0.0.1... * connected * Connected to git.local (127.0.0.1) port 80 (#0) > PROPFIND /new/ HTTP/1.1 User-Agent: git/1.7.1 Host: git.local Accept: */* Depth: 0 Content-Type: text/xml Content-Length: 167 Expect: 100-continue < HTTP/1.1 401 Authorization Required < Date: Tue, 23 Nov 2010 16:21:51 GMT < Server: Apache/2.2.16 (Ubuntu) < WWW-Authenticate: Basic realm="Private Git Access" < Vary: Accept-Encoding < Content-Length: 476 < Content-Type: text/html; charset=iso-8859-1 < * Expire cleared * Closing connection #0 * Issue another request to this URL: 'http://shoaibi:[email protected]/new/' * Couldn't find host git.local in the .netrc file; using defaults * About to connect() to git.local port 80 (#0) * Trying 127.0.0.1... * connected * Connected to git.local (127.0.0.1) port 80 (#0) * Server auth using Basic with user 'shoaibi' > PROPFIND /new/ HTTP/1.1 Authorization: Basic c2hvYWliaTpzaG9haWJp User-Agent: git/1.7.1 Host: git.local Accept: */* Depth: 0 Content-Type: text/xml Content-Length: 167 Expect: 100-continue < HTTP/1.1 100 Continue * The requested URL returned error: 405 * Expire cleared * Closing connection #0 error: Cannot access URL http://shoaibi:[email protected]/new/, return code 22 fatal: git-http-push failed
Apache的日志说:
127.0.0.1 - - [23/Nov/2010:21:21:51 +0500] "GET /new/info/refs?service=git-receive-pack HTTP/1.1" 401 725 127.0.0.1 - shoaibi [23/Nov/2010:21:21:51 +0500] "GET /new/info/refs?service=git-receive-pack HTTP/1.1" 200 231 127.0.0.1 - shoaibi [23/Nov/2010:21:21:51 +0500] "GET /new/HEAD HTTP/1.1" 200 256 127.0.0.1 - - [23/Nov/2010:21:21:51 +0500] "PROPFIND /new/ HTTP/1.1" 401 725 127.0.0.1 - shoaibi [23/Nov/2010:21:21:51 +0500] "PROPFIND /new/ HTTP/1.1" 405 553
git-http-backend需要启用cgi,alias和env mods,这些已经启用了,我甚至在google上阅读了一些结果之后尝试启用和禁用dav相关模块。 Apache的启用模块:
$apache2ctl -M Loaded Modules: core_module (static) log_config_module (static) logio_module (static) mpm_prefork_module (static) http_module (static) so_module (static) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cache_module (shared) cgi_module (shared) dav_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) mem_cache_module (shared) mime_module (shared) security2_module (shared) negotiation_module (shared) php5_module (shared) proxy_module (shared) proxy_ajp_module (shared) proxy_balancer_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) ssl_module (shared) status_module (shared) unique_id_module (shared) userdir_module (shared) Syntax OK
Apache的Vhost:
<VirtualHost *:80> ServerName www.git.local ServerAlias git.local ServerAdmin [email protected] DocumentRoot /var/www/git/ SetEnv GIT_PROJECT_ROOT /var/www/git SetEnv GIT_HTTP_EXPORT_ALL ScriptAlias /git/ /usr/lib/git-core/git-http-backend <Directory /> Options +ExecCGI Allow From All </Directory> <Location /> AuthType Basic AuthName "Private Git Access" Require group committers AuthUserFile /var/www/git/.htpasswd AuthGroupFile /var/www/git/.htgroup </Location> ErrorLog /var/log/apache2/git-error_log CustomLog /var/log/apache2/git-access_log common </VirtualHost>
htpasswd的:
$ cat .htpasswd shoaibi:HSt/9CzkstIUM
htgroup:
$ cat .htgroup committers: shoaibi
目录结构:
$ ls -al total 28 drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 17:05 . drwxrwxr-x 17 www-data shoaibi 4096 2010-11-23 11:46 .. -rwxrwxr-x 1 www-data shoaibi 20 2010-11-23 16:51 .htgroup -rwxrwxr-x 1 www-data shoaibi 22 2010-11-23 16:50 .htpasswd -rwxrwxr-x 1 www-data shoaibi 9 2010-11-23 15:46 index.html drwxrwxr-x 7 www-data shoaibi 4096 2010-11-23 11:53 myrepo.git drwxrwxr-x 7 www-data shoaibi 4096 2010-11-23 17:05 new $ ls -al new total 40 drwxrwxr-x 7 www-data shoaibi 4096 2010-11-23 17:05 . drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 17:05 .. drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 17:05 branches -rwxrwxr-x 1 www-data shoaibi 66 2010-11-23 17:05 config -rwxrwxr-x 1 www-data shoaibi 73 2010-11-23 17:05 description -rwxrwxr-x 1 www-data shoaibi 23 2010-11-23 17:05 HEAD drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 17:05 hooks drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 20:30 info drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 17:05 objects drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 17:05 refs $ ls -al myrepo.git total 40 drwxrwxr-x 7 www-data shoaibi 4096 2010-11-23 11:53 . drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 17:05 .. drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 11:53 branches -rwxrwxr-x 1 www-data shoaibi 66 2010-11-23 11:53 config -rwxrwxr-x 1 www-data shoaibi 73 2010-11-23 11:53 description -rwxrwxr-x 1 www-data shoaibi 23 2010-11-23 11:53 HEAD drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 11:53 hooks drwxrwxr-x 2 www-data shoaibi 4096 2010-11-23 16:20 info drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 11:53 objects drwxrwxr-x 4 www-data shoaibi 4096 2010-11-23 11:53 refs
看着你的VHost文件,我不确定git后端是否正在发射。
ScriptAlias /git/ /usr/lib/git-core/git-http-backend
这实际上不会做任何事情,除非你在一个页面,如http://git.local/git/somethingelse – 因为你的DocumentRoot是/ var / www / git /,而你的仓库是/ var / www下的文件夹/ git / ScriptAlias行没有任何用处,因为你永远不会浏览http://git.local/git/
你在/var/www/git/new设置了git config http.receivepack true吗?