ユーザ用ツール

サイト用ツール


ubuntu-server-14-04:git-server

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
ubuntu-server-14-04:git-server [2015/01/07 19:48] – 作成 adminubuntu-server-14-04:git-server [2015/01/07 22:50] (現在) admin
行 1: 行 1:
-====== 参考 ======+====== Git サーバのインストール ======
  
 +バージョン管理ソフトの Git をインストールする。
  
-  * [[http://blog.anatoo.jp/entry/20120619/1340033935]]+主に以下の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 をインストールする。 
 + 
 +<code> 
 +$ sudo apt-get install git-core 
 +</code> 
 + 
 + 
 +==== モジュールを有効化 ==== 
 + 
 + 
 +git-http-backend は Apache2 上で動作し、mod_cgi、mod_alias、mod_env モジュールが必要。デフォルトでは、mod_cgi が無効になっている。 
 + 
 +<code> 
 +$ sudo a2enmod cgi alias env 
 +</code> 
 + 
 +Apache2 のサイトの設定を変更する。[[apache2-ssl|以前作成]]した、SSL を使用するサイトの <VirtualHost> ディレクティブ内に以下を記述する。認証に使用するパスワードは、[[webdav|WebDav をインストール]]した際に作成したものを利用する。  
 + 
 +  * /var/www/git: Git リポジトリを格納するディレクトリ。複数のリポジトリを格納する予定。 
 + 
 +<code> 
 +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/ 
 + 
 +<Location /git> 
 +        SSLRequireSSL 
 +        SSLOptions +StrictRequire 
 +        AuthType Basic 
 +        AuthName "Git Authentication" 
 +        AuthUserFile /etc/apache2/dav.passwd 
 +        Require valid-user 
 +</Location> 
 + 
 +</code> 
 + 
 +設定ファイルの構文チェックを行う。 
 + 
 +<code> 
 +$ sudo apache2ctl configtest 
 +</code> 
 + 
 +Apache2 を再起動する。 
 + 
 +<code> 
 +$ sudo service apache2 restart 
 +</code> 
 + 
 + 
 +==== テスト用のリポジトリを作成 ==== 
 + 
 +テスト用にリポジトリを作成する。 
 + 
 +<code> 
 +$ 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 . 
 +</code> 
 + 
 +クライアントからアクセスし、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]]
ubuntu-server-14-04/git-server.1420627723.txt.gz · 最終更新: 2015/01/07 19:48 by admin