码迷,mamicode.com
首页 > 其他好文 > 详细

centos6 配置 nginx + fcgiwrap + git

时间:2015-08-12 17:06:46      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:

安装源

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release*rpm
yum install fcgi-devel spawn-fcgi -y


编译安装fcgiwrap

git clone git://github.com/gnosek/fcgiwrap.git
cd fcgiwrap
autoreconf -i
./configure
make
make install


配置fcgiwrap开机脚本

vim /etc/init.d/fcgiwrap
#! /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
chmod +x fcgiwrap
chkconfig fcgiwrap on


添加git的fastcgi配置 

vim /path/to/nginx/conf/fastcgi_params_git
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_param  REMOTE_USER        $remote_user;
# required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;


添加git server的nginx配置 

server {
 listen   80;
 server_name  mydevserver;
 access_log /var/log/nginx/dev.access.log;
 error_log /var/log/nginx/dev.error.log;
 location / {
  root  /var/repos;
 }
 location ~ /git(/.*) {
  gzip off;
  root /usr/lib/git-core;
  fastcgi_pass  unix:/var/run/fcgiwrap.socket;
  include fastcgi_params_git;
  fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
  fastcgi_param DOCUMENT_ROOT /usr/lib/git-core/;
  fastcgi_param SCRIPT_NAME git-http-backend;
  fastcgi_param GIT_HTTP_EXPORT_ALL "";
  fastcgi_param GIT_PROJECT_ROOT /var/repos;
  fastcgi_param PATH_INFO $1;
  #fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
 }
}

注意git-http-backend的路径对不对

centos6 配置 nginx + fcgiwrap + git

标签:

原文地址:http://my.oschina.net/Corz/blog/491269

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!