Nginx+git
gitインストール
# sudo apt-get install git
リポジトリ作成
# mkdir -p /var/git/repository/test.git # cd /var/git/repository/test.git # git --bare init --shared=group
コミット
# mkdir ~/test # cd ~/test # git init # echo "Hello git project" > README # git add . # git commit -m "test" # git push /var/git/repository/test.git master
nginx fcgiwrapインストール
# sudo apt-get install nginx fcgiwrap
Nginx設定
location /repository { # IP制限など allow XXX.XXX.XXX.XXX; deny all; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; fastcgi_param GIT_PROJECT_ROOT /var/git; fastcgi_param GIT_HTTP_EXPORT_ALL ""; fastcgi_param PATH_INFO $uri; fastcgi_param REMOTE_USER $remote_user; fastcgi_pass unix:/var/run/fcgiwrap.socket; }
hooks設定
# cd /var/git/repository/test.git # cp hooks/post-update.sample hooks/post-update # git update-server-info # git config http.receivepack true
fcgiwrapのソケットユーザをnginxにしておく
# vi /etc/init.d/fcgiwrap FCGI_SOCKET="/var/run/$NAME.socket"FCGI_USER="nginx" FCGI_GROUP="nginx" # Socket owner/group (will default to FCGI_USER/FCGI_GROUP if not defined) FCGI_SOCKET_OWNER="nginx" FCGI_SOCKET_GROUP="nginx"
再起動
# sudo /etc/init.d/fcgiwrap restart # sudo /etc/init.d/nginx restart
ローカルからgit clone
# git clone http://my_domain/repository/test.git
参考 http://serverfault.com/questions/334127/howto-nginx-git-http-backend-fcgiwrap-debian-squeeze http://zuqqhi2.com/?p=735