[HowTo] gitサーバをApacheで公開する手順
2013年3月4日Subversionに続いて、gitサーバを公開する手順の覚書。
- Apache、gitの入手
面倒なので、yumでインストール
yum install -y httpd git
※Apacheの設定などは適宜変更します
- git向けのApache設定
※あくまで参考までに
<VirtualHost *:80> ServerName hoge.com # 適宜変更 Redirect / https://hoge.com/ # 適宜変更 </VirtualHost> <VirtualHost *:443> ServerName hoge.com # 適宜変更 ServerAlias hoge.com # 適宜変更 DocumentRoot "/var/git/" # 適宜変更 SetEnv GIT_PROJECT_ROOT /home/git/ SetEnv GIT_HTTP_EXPORT_ALL <Directory "/var/git/"> # 適宜変更 AllowOverride All Options Indexes FollowSymLinks Includes ExecCGI MultiViews order deny,allow deny from all Allow from 127.0.0.1 Allow from 192.168.1. # 適宜変更 </Directory> <Location /> DAV on SSLRequireSSL AuthType Basic AuthName "git repository" AuthUserFile /var/htpasswd.git # 適宜変更 <Limitexcept GET HEAD PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> </Location> </VirtualHost>
設定語、Apacheをリスタート or reload
- gitディレクトリの作成
公開するgitサーバのディレクトリの作成と初期化
mkdir -p /var/git/tutorial.git cd /var/git/tutorial.git git --bare init --shared git update-server-info chown -R apache. .
- 確認
https://hoge.com/tutorial.gitへアクセスして、表示確認
問題なければ、pullしたり、pushしたり,fetchしたり・・・
- 補足
上記の設定で行くと、証明書(CA)は、俗に言うオレオレ証明書となる。
そのため、以下のコマンドでSSL証明書の確認をキャンセル設定してあげると、うまくいく。
git config --global --add http.sslVerify false
※Windowsの場合は、GitBashから。