Git, Debian, Apache и Smart HTTP
Я пытаюсь настроить git на своем сервере Debian. Тем не менее, я схожу с ума по поводу этого Smart HTTP, так как я хочу использовать плагин Egit для eclipse, и он требует Smart HTTP. И по этой причине я не могу перенести мою локальную ветку в удаленный репозиторий на моем сервере. Я установил Apache и Git 1.7.2.3. Я использую обычную аутентификацию и включил mod_cgi
, mod_env
а также mod_alias
, Мой конфигурационный файл apache для git /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, что удаленный Smart HTTP не включен. Что мне не хватает?
Заранее спасибо, Андреас
2 ответа
Отвечая на мой собственный вопрос: я заменил 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
директивы.
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