Ubuntu, Git (git-http-backend) and Apache

apache-2.2gitUbuntu

I am trying to setup a repository server based on git combine with its git-http-backend and apache. My problem? I can clone perfectly, but when i try ti push, i hit a wall

$ 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:shoaibi@git.local/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:shoaibi@git.local/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:shoaibi@git.local/new/, return code 22
fatal: git-http-push failed

Apache's Logs say:

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 requires cgi, alias and env mods enabled, these are already enabled, i even tried enabled and disabling dav related modules after reading some results on google. Apache's enabled modules:

 $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's Vhost:

<VirtualHost *:80>
        ServerName www.git.local
        ServerAlias git.local
        ServerAdmin webmaster@git.local
        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

Directory Structure:

$ 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

Best Answer

Looking at your VHost file I'm not sure the git backend is firing at all.

ScriptAlias /git/ /usr/lib/git-core/git-http-backend

This won't actually do anything unless you're on a page such as http://git.local/git/somethingelse - As your DocumentRoot is /var/www/git/ , and your repositories are folders under /var/www/git/ the ScriptAlias line serves no purpose as you will never be navigating http://git.local/git/