1. 安装Fastcgiwrap
1 2 3 4 5 6 7 8 9 10 11 12 13 |
yum install fcgi-devel spawn-fcgi git clone git://github.com/gnosek/fcgiwrap.git cd fcgiwrap autoreconf -i ./configure make make install |
vi /etc/init.d/fcgiwrap
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#! /bin/sh # chkconfig: 2345 55 25 DESC="fcgiwrap daemon" DEAMON=/usr/bin/spawn-fcgi PIDFILE=/var/run/spawn-fcgi.pid FCGI_SOCKET=/var/run/fcgiwrap.socket FCGI_PROGRAM=/usr/local/sbin/fcgiwrap FCGI_USER=www FCGI_GROUP=www 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 |
start fcgiwrap
nginx.conf
1 2 3 4 5 6 7 8 9 10 |
location ~ /git(/.*) { auth_basic "Restricted"; fastcgi_pass unix:/var/run/fcgiwrap.socket; auth_basic_user_file /etc/nginx.passwd; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend; fastcgi_param GIT_PROJECT_ROOT /var/git-repos; fastcgi_param GIT_HTTP_EXPORT_ALL true; fastcgi_param PATH_INFO $1; fastcgi_param REMOTE_USER $remote_user; |
1 2 3 |
cd /var/git-repos git init --bare my-project.git htpasswd -c /etc/nginx.passwd user1 |
restart nginx
git clone https://www.xiaohui.org/git/my-project.git
http://qiita.com/egnr-in-6matroom/items/2a052339ee0515b31fdf