3

我正在尝试在我的 Debian 服务器上设置 git。但是,我对这个 Smart HTTP 的东西很着迷,因为我想为 eclipse 使用 Egit 插件并且它需要 Smart HTTP。因此,我无法将本地分支推送到服务器上的远程存储库。我已经安装了 Apache 和 Git 1.7.2.3。我正在使用基本身份验证并已启用mod_cgi,mod_envmod_alias. 我的 git 东西的 apache 配置文件位于/etc/apache2/sites-available/git并包含以下内容:

 <VirtualHost *:80>
         Servername git.mydomain.com
         DocumentRoot /var/git
         SetEnv GIT_PROJECT_ROOT /var/git/
         SetEnv GIT_HTTP_EXPORT_ALL
         ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
         <Directory "/var/git">
            DAV On
            Options +Indexes +FollowSymLinks
            Deny from all
            AuthType Basic
            AuthName "git repository"
            AuthUserFile /var/git/.htpasswd
            AuthGroupFile /var/git/.htgroup
         </Directory>
         <Directory /var/git/allternative>
                 Allow from all
                 Order allow,deny
                 Require group allternative
         </Directory>
         <Directory "/usr/lib/git-core/git-receive-pack">
                 Allow from all
                 Order allow,deny
                 Require group allternative
         </Directory>
 </VirtualHost>

目录如下:

  • /var/git:这是我所有存储库的目录
  • /var/git/allternative:这是我目前正在尝试设置的(裸)存储库所在的目录

我做了我在这篇文章中读到的所有内容(还有许多其他人也这么说): http: //progit.org/2010/03/04/smart-http.html

我仍然收到来自 Egit 的错误,即远程智能 HTTP 未启用。我错过了什么?

提前致谢, 安德烈亚斯

4

2 回答 2

4

回答我自己的问题:我将ScriptAlias指令替换为:

  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 REMOTE_USER=$REDIRECT_REMOTE_USER

然后它起作用了。我在http://www.espace.com.eg/blog/2010/11/10/migrating-from-subversion-to-git/上找到了这两个设置,我不确定这两个设置中的哪一个解决了问题,但我认为这是SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER指令。

于 2011-11-10T15:54:15.277 回答
3

ServerAdmin     admin@server.ru
ServerName      git.server.ru
ServerAlias     git
UseCanonicalName Off

# path to repo
DocumentRoot    /srv/git
DavLockDB "/var/lock/davlock"

SetEnv GIT_PROJECT_ROOT /srv/git
SetEnv GIT_HTTP_EXPORT_ALL
#in Progit http://progit.org/2010/03/04/smart-http.html next line is omitted and
#we get an error. So next line is a mandatory requirement.
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

#Don't uncomment line below. It's a second error.
#ScriptAlias / /usr/lib/git-core/git-http-backend/

#but this works

 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"

 #making accessible scripts
  <Directory /usr/lib/git-core/>
      Options +ExecCGI
  Order Allow,Deny      
  Allow from all
  </Directory>

 #opening access to our git repos
 <Directory /srv/git>
Dav on
Order Allow,Deny        
Allow from all
Options +Indexes                       
</Directory>

#need only for auth.
<LocationMatch "^.*/git-receive-pack$">
    AuthType Basic
    AuthName "Git Access"
    AuthUserFile /srv/git/passwd.git
    Require valid-user
</LocationMatch>

LogLevel warn
ErrorLog /var/log/httpd/git-error.log        
CustomLog /var/log/httpd/git-access.log combined

于 2012-04-07T07:02:32.780 回答