git + nginx + fcgiwrap + spawn-fcgi git的http服务器

环境

  • Centos/Redhat 6
  • 安装好 git

安装 fcgiwrap

安装 spawn-fcgi

编辑 spawn-fcgi/sbin/fcgiwrap 开机启动脚本:

#! /bin/sh
DESC="fcgiwrap daemon"
DEAMON=/opt/spawn-fcgi/bin/spawn-fcgi
PIDFILE=/tmp/spawn-fcgi.pid
# fcgiwrap socket
FCGI_SOCKET=/tmp/fcgiwrap.socket
# fcgiwrap 可执行文件
FCGI_PROGRAM=/opt/fcgiwrap/sbin/fcgiwrap
# fcgiwrap 执行的用户和用户组
FCGI_USER=nobody
FCGI_GROUP=nobody
FCGI_EXTRA_OPTIONS="-M 0770"
OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P $PIDFILE -- $FCGI_PROGRAM"
do_start() {
 $DEAMON $OPTIONS || echo -n "$DESC already running"
}
do_stop() {
 kill -INT `cat $PIDFILE` || echo -n "$DESC not running"
}
case "$1" in
 start)
  echo -n "Starting $DESC: $NAME"
  do_start
  echo "."
  ;;
 stop)
  echo -n "Stopping $DESC: $NAME"
  do_stop
  echo "."
  ;;
 restart)
  echo -n "Restarting $DESC: $NAME"
  do_stop
  do_start
  echo "."
  ;;
 *)
  echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
  exit 3
  ;;
esac
exit 0

启动 fcgiwrap

chmod 0755 /opt/spawn-fcgi/sbin/fcgiwrap
/opt/spawn-fcgi/sbin/fcgiwrap start

安装 nginx

在 nginx 前端目录 html 下创建 git 仓库目录 nginx/html/git/

mkdir /opt/nginx/html/git/
chown nobody.nobody /opt/nginx/html/git/ -R

配置 nginx 的 git 服务

# 在 server section 中添加 git
location ~ /git(/.*) {
    gzip off;
    fastcgi_pass  unix:/tmp/fcgiwrap.socket;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
    fastcgi_param GIT_HTTP_EXPORT_ALL "";
    fastcgi_param GIT_PROJECT_ROOT /opt/nginx/html/git;
    fastcgi_param PATH_INFO $1;
    fastcgi_param REMOTE_USER $remote_user;
    client_max_body_size 500m;
}

重新加载配置文件

/opt/nginx/sbin/nginx -s reload

测试,在仓库目录下新建一个空repo

cd /opt/nginx/html/git/
git init --bare test-repo
chown nobody.nobody test-repo -R
cd test-repo
git config http.reveivepack true

完成

  • 在另一台服务器中可以顺利的进行 clone、push 及 pull 等操作。

转载于:https://my.oschina.net/colben/blog/791046

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值