centos 配置 nginx + fcgiwrap + git

前端之家收集整理的这篇文章主要介绍了centos 配置 nginx + fcgiwrap + git前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、编译安装fcgiwrap

  1. git clone git://github.com/gnosek/fcgiwrap.git
  2. cd fcgiwrap
  3. autoreconf -i
  4. ./configure
  5. make
  6. make install

2、配置fcgiwrap开机脚本

  1. vim /etc/init.d/fcgiwrap
  1. #! /bin/sh
  2. # chkconfig: 2345 55 25
  3. DESC="fcgiwrap daemon"
  4. DEAMON=/usr/bin/spawn-fcgi
  5. PIDFILE=/var/run/spawn-fcgi.pid
  6. FCGI_SOCKET=/var/run/fcgiwrap.socket
  7. FCGI_PROGRAM=/usr/local/sbin/fcgiwrap
  8. FCGI_USER=www
  9. FCGI_GROUP=www
  10. FCGI_EXTRA_OPTIONS="-M 0770"
  11. OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P $PIDFILE -- $FCGI_PROGRAM"
  12. do_start() {
  13. $DEAMON $OPTIONS || echo -n "$DESC already running"
  14. }
  15. do_stop() {
  16. kill -INT `cat $PIDFILE` || echo -n "$DESC not running"
  17. }
  18. case "$1" in
  19. start)
  20. echo -n "Starting $DESC: $NAME"
  21. do_start
  22. echo "."
  23. ;;
  24. stop)
  25. echo -n "Stopping $DESC: $NAME"
  26. do_stop
  27. echo "."
  28. ;;
  29. restart)
  30. echo -n "Restarting $DESC: $NAME"
  31. do_stop
  32. do_start
  33. echo "."
  34. ;;
  35. *)
  36. echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
  37. exit 3
  38. ;;
  39. esac
  40. exit 0

增加执行权限并开启

  1. chmod +x fcgiwrap
  2. chkconfig fcgiwrap on

添加git的fastcgi配置

  1. vim /path/to/Nginx/conf/fastcgi_params_git
  1. fastcgi_param QUERY_STRING $query_string;
  2. fastcgi_param REQUEST_METHOD $request_method;
  3. fastcgi_param CONTENT_TYPE $content_type;
  4. fastcgi_param CONTENT_LENGTH $content_length;
  5. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  6. fastcgi_param REQUEST_URI $request_uri;
  7. fastcgi_param DOCUMENT_URI $document_uri;
  8. fastcgi_param DOCUMENT_ROOT $document_root;
  9. fastcgi_param SERVER_PROTOCOL $server_protocol;
  10. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  11. fastcgi_param SERVER_SOFTWARE Nginx/$Nginx_version;
  12. fastcgi_param REMOTE_ADDR $remote_addr;
  13. fastcgi_param REMOTE_PORT $remote_port;
  14. fastcgi_param SERVER_ADDR $server_addr;
  15. fastcgi_param SERVER_PORT $server_port;
  16. fastcgi_param SERVER_NAME $server_name;
  17. fastcgi_param REMOTE_USER $remote_user;
  18. # required if PHP was built with --enable-force-cgi-redirect
  19. fastcgi_param REDIRECT_STATUS 200;

添加git server的Nginx配置

  1. server {
  2. listen 80;
  3. server_name mydevserver;
  4. access_log /var/log/Nginx/dev.access.log;
  5. error_log /var/log/Nginx/dev.error.log;
  6. location / {
  7. root /var/repos;
  8. }
  9. location ~ /git(/.*) {
  10. gzip off;
  11. root /usr/lib/git-core;
  12. fastcgi_pass unix:/var/run/fcgiwrap.socket;
  13. include fastcgi_params_git;
  14. fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
  15. fastcgi_param DOCUMENT_ROOT /usr/libexec/git-core/;
  16. fastcgi_param SCRIPT_NAME git-http-backend;
  17. fastcgi_param GIT_HTTP_EXPORT_ALL "";
  18. fastcgi_param GIT_PROJECT_ROOT /var/repos;
  19. fastcgi_param PATH_INFO $1;
  20. #fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  21. }
  22. }

注意 git-http-backend路径

附:

1、 Cannot access URL错误

  1. error: Cannot access URL http://www.example.com/git/projects/example/,return code 22

仓库下:

  1. git config http.receivepack true
  1. 安装编译fcgiwrap
  1. configure: error: FastCGI library is missing

安装fcgi-devel

  1. yum install fcgi-devel -y

猜你在找的CentOS相关文章