Accesso ad un repository Git tramite Apache git-httpd-backend

From RVM Wiki
Jump to navigation Jump to search
  • Abilitare i moduli apache necessari
sudo a2enmod cgi alias env
  • Creare il file di configurazione di apache:
sudoedit /etc/apache2/conf.d/git
SetEnv GIT_PROJECT_ROOT /files/git/repos
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
  • Se si vuole usare l'autenciazione su file, inserire:
<Location /git>
    AuthType Basic
    AuthName "Private Git Access"
    AuthUserFile /files/git/htpasswd.git
    Require valid-user
</Location>
  • Creare il file di autenticazione:
sudo -u www-data htpasswd -c /files/git/htpasswd.git diesis
<Location /git>
  AuthType Basic
  AuthName "Private GitWeb Access"
  Require valid-user
  AuthBasicProvider external
  AuthExternal pwauth
</Location>


sudo invoke-rc.d apache2 restart
  • Creare il repository vuoto:
sudo mkdir -p /files/git/repos/etc
cd /files/git/repos/etc
sudo git init --bare
  • Attivare l'hook di post-update:
sudo mv hooks/post-update.sample hooks/post-update
  • Sistemare le permission
sudo chmod -R g=rwX .
sudo chmod -R o= .
sudo chown -R :www-data /files/git/
  • Clonare in locale il repository vuoto
cd ~
mkdir test
cd test
git clone http://diesis@localhost/git/etc
  • Fare il primo commit e push:
cd etc/
touch readme
git add readme
git commit -m "first commit"
git push origin master
  • I push successivi possono essere fatti normalmente:
git push

Git-http-backend