====== Git サーバのインストール ====== バージョン管理ソフトの Git をインストールする。 主に以下の3通りの方法でインストールするのが主流らしい。 - Git をインストールして SSH 経由で接続する - Git をインストールして git-http-backend に対して HTTP 経由で接続する - WebDab 上にリポジトリを作成して HTTP 経由で接続する WebDav は遅いらしい。接続する人が増えるたびに SSH の鍵作るのもいやなので、git-http-backend を使う方法に決定。 ===== 環境 ===== ==== インストール前の環境 ==== * Ubuntu 14.04.1 LTS 64bit ^ パッケージ名 ^ バージョン ^ | apache2 | 2.4.7-1ubuntu4.1 | Apache2 はすでに稼働中。 ==== インストールするパッケージ等 ==== ^ パッケージ名 ^ バージョン ^ | git-core | 1:1.9.1-1 | ===== インストールと設定 ===== ==== パッケージをインストール ==== Git をインストールする。 $ sudo apt-get install git-core ==== モジュールを有効化 ==== git-http-backend は Apache2 上で動作し、mod_cgi、mod_alias、mod_env モジュールが必要。デフォルトでは、mod_cgi が無効になっている。 $ sudo a2enmod cgi alias env Apache2 のサイトの設定を変更する。[[apache2-ssl|以前作成]]した、SSL を使用するサイトの ディレクティブ内に以下を記述する。認証に使用するパスワードは、[[webdav|WebDav をインストール]]した際に作成したものを利用する。 * /var/www/git: Git リポジトリを格納するディレクトリ。複数のリポジトリを格納する予定。 SetEnv GIT_PROJECT_ROOT /var/www/git AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1 AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1 ScriptAlias /git/ /usr/lib/git-core/git-http-backend/ SSLRequireSSL SSLOptions +StrictRequire AuthType Basic AuthName "Git Authentication" AuthUserFile /etc/apache2/dav.passwd Require valid-user 設定ファイルの構文チェックを行う。 $ sudo apache2ctl configtest Apache2 を再起動する。 $ sudo service apache2 restart ==== テスト用のリポジトリを作成 ==== テスト用にリポジトリを作成する。 $ sudo mkdir /var/www/git $ cd /var/www/git/ $ sudo mkdir ./test.git $ cd ./test.git/ $ sudo git init --bare $ sudo git config http.receivepack true $ sudo git update-server-info $ sudo touch ./git-daemon-export-ok $ sudo cp ./hooks/post-update.sample ./hooks/post-update $ sudo chown -R www-data:www-data . クライアントからアクセスし、Git にアクセスできるかを確認する。 ===== 参考 ===== * [[https://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html|git-http-backend(1) Manual Page]] * [[http://blog.coffeebeans.at/?p=734|Apache2 with Git Smart HTTP]] * [[http://blog.anatoo.jp/entry/20120619/1340033935| gitリポジトリをホストするのにWebDAV使わないほうがいい ]] * [[http://git-scm.com/2010/03/04/smart-http.html|Smart HTTP Transport]]