http://linuxjcq.blog.51cto.com/3042600/718002

原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://linuxjcq.blog.51cto.com/3042600/718002

1. 下载spawn-fcgi并安装

  1. http://download.lighttpd.net/spawn-fcgi/releases-1.6.x/spawn-fcgi-1.6.3.tar.gz -P /usr/local/src
  2. tar zxvf /usr/local/src/spawn-fcgi-1.6.3.tar.gz -P /usr/local/src
  3. cd /usr/local/src/spawn-fcgi-1.6.3
  4. ./configure
  5. make
  6. # 复制spawn-fcgi到/usr/local/bin/
  7. cp spawn-fcgi /usr/local/bin

2. 下载并安装fcgi库

  1. wget http://fastcgi.com/dist/fcgi-2.4.0.tar.gz -P /usr/local/src
  2. tar zxvf /usr/local/src/fcgi-2.4.0.tar.gz -C /usr/ocal/src
  3. cd /usr/local/src/fcgi-2.4.0
  4. ./configure
  5. make
  6. make install

编译过程有报错

  1. error: 'EOF' was not declared in this scope

解决办法:在include/fcgio.h文件中加上#include <cstdio>

  1. vi include/fcgio.h
  2. #include <iostream>
  3. # 添加下行
  4. #include <cstdio>

3. 安装fcgiwrap

  1. wget https://download.github.com/gnosek-fcgiwrap-1.0.3-4-g58ec209.tar.gz -P /usr/locl/src
  2. tar zxvf /usr/local/src/gnosek-fcgiwrap-1.0.3-4-g58ec209.tar.gz -P /usr/local/src
  3. cd /usr/local/src/gnosek-fcgiwrap-58ec209
  4. autoreconf -i
  5. export ac_cv_func_malloc_0_nonnull=yes
  6. ./configure
  7. make
  8. # 复制fcgiwrap
  9. cp fcgiwrap /usr/local/bin

4. 创建启动和管理脚本

  1. vi /etc/rc.d/init.d/cfcgi
  2. #!/bin/bash
  3. # cfcgi – this script starts and stops the fcgiwrap instance
  4. #
  5. # chkconfig: – 96 28
  6. # description: cfcgi
  7. # processname: cfcgi
  8. RETVAL=0
  9. case "$1" in
  10. start)
  11. echo "Starting fastcgi"
  12. /usr/local/bin/spawn-fcgi -f /usr/local/bin/fcgiwrap -a 192.168.1.10 -p 10000 -F 32 -P /tmp/fastcgi-c.pid -u nobody -g nobody
  13. RETVAL=$?
  14. ;;
  15. stop)
  16. echo "Stopping fastcgi"
  17. killall -9 fcgiwrap
  18. RETVAL=$?
  19. ;;
  20. restart)
  21. echo "Restarting fastcgi"
  22. killall -9 fcgiwrap
  23. /usr/local/bin/spawn-fcgi -f /usr/local/bin/fcgiwrap -a 192.168.1.10 -p 10000 -F 32 -P /tmp/fastcgi-c.pid -u nobody -g nobody
  24. RETVAL=$?
  25. ;;
  26. *)
  27. echo "Usage: c-fastcgi {start|stop|restart}"
  28. exit 1
  29. ;;
  30. esac
  31. exit $RETVAL

这个脚本是salogs.com中的,直接拿来用了

添加为服务

  1. chmod 0755 /etc/rc.d/init.d/cfcgi
  2. chown root:root /etc/rc.d/init.d/cfcgi
  3. chkconfig –add cfcgi
  4. chkconfig cfcgi on

5. 启动

  1. service cfcgi start

检验下:

  1. netstat -tlnp | grep "fcgiwrap"
  2. tcp 0 0 192.168.1.10:10000 0.0.0.0:* LISTEN 4021/fcgiwrap
  3. ps -ef | grep "fcgi"
  4. nobody 4021 1 0 18:34 ? 00:00:00 /usr/local/bin/fcgiwrap

注意配置文件中是以nobody身份运行的

6. 配置nginx

  1. location ~ .*\.cgi$
  2. {
  3. fastcgi_pass 192.168.1.10:10000;
  4. include fcgi.conf;
  5. }

配置文件fcgi.conf和php公用为:

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

OK,配置完成

参考文档:http://nginx.localdomain.pl/wiki/FcgiWrap http://salogs.com/

本文出自 “linuxjcq” 博客,请务必保留此出处http://linuxjcq.blog.51cto.com/3042600/718002

spawn-fcgi运行fcgiwrap的更多相关文章

  1. lighttpd与fastcgi+cgilua原理、代码分析与安装

    原理 http://www.cnblogs.com/skynet/p/4173450.html 快速通用网关接口(Fast Common Gateway Interface/FastCGI)是通用网关 ...

  2. Nginx系列2之Nginx+php

    preface 公司所有的大多数业务都泡在LNMP平台上,所以对PHP+Nginx有点了解,那么就做个小小的总结吧. what's FastCGi FastCGI是一个可伸缩,高速的在HTTP ser ...

  3. Python—进程、线程、协程

    一.线程 线程是操作系统能够进行运算调度的最小单位.它被包含在进程之中,是进程中的实际运作单位.一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行不同的任务 方法: ...

  4. nodeJS 菜鸟入门

    从一个简单的 HTTP 服务开始旅程-- 创建一个 server.js 文件,写入: //最简单的 http 服务例子 var http = require("http"); ht ...

  5. python三大神器之一fabric使用

    fabric 是一个python包 是一个基于ssh的部署工具包 通常用来对网站 微服务等等的批量部署 例如 我有5台线上服务器 可以通过一台对着5台分发,实现自动部署的目的. 简单介绍下 fabri ...

  6. python---协程 学习笔记

    协程 协程又称为微线程,协程是一种用户态的轻量级线程 协程拥有自己的寄存器和栈.协程调度切换的时候,将寄存器上下文和栈都保存到其他地方,在切换回来的时候,恢复到先前保存的寄存器上下文和栈,因此:协程能 ...

  7. nodejs(二)child_process模块

    1.child_process是Node.js的一个十分重要的模块,通过它可以实现创建多进程,以利用多核计算资源. child_process模块提供了四个创建子进程的函数,分别是spawn,exec ...

  8. Node.js进程通信模块child_process

    前言 Node.js是一种单线程的编程模型,对Node.js的赞美和诟病的也都是因为它的单线程模型,所有的任务都在一个线程中完成(I/O等例外).单线程模型,不仅让代码非常简洁,更是直接避免了线程调度 ...

  9. python_线程、进程和协程

    线程 Threading用于提供线程相关的操作,线程是应用程序中工作的最小单元. #!/usr/bin/env python #coding=utf-8 __author__ = 'yinjia' i ...

随机推荐

  1. MT6592 经验积累

    1.build/target/product/xxxx.mk  新项目clone后,需要修改这里 如:build/target/product/x160v.mk PRODUCT_MODEL :=Phi ...

  2. iOS9 ReplayKit录制视频

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2Der-CSDN,谢谢! 原文地址: http://blog.csdn.net/cocos2der/article/details/50260873 ...

  3. 高通Android display架构分析

    目录(?)[-] Kernel Space Display架构介绍 函数和数据结构介绍 函数和数据结构介绍 函数和数据结构介绍 数据流分析 初始化过程分析 User Space display接口 K ...

  4. LeetCode(63)-First Bad Version

    题目: You are a product manager and currently leading a team to develop a new product. Unfortunately, ...

  5. How to configure ODBC DSN to access local DB2 for Windows

    How to configure ODBC DSN to access local DB2 for Windows MA Genfeng (GuangdongUnitoll Services inco ...

  6. sxoi爆炸祭

    好吧,纯粹是去玩玩的,我这么一个弱省的蒟蒻,进队纯粹是开玩笑.... Day0 去五中试机,感觉电脑手感不错,打了半个线段树的板子才发现试机要在自己的电脑上试,然后我无奈的搬东西(从26号搬到2号), ...

  7. <mate name="viewport">移动端设置详解

    <meta name="viewport" content="width=device-width,height=device-height,initial-sca ...

  8. java基础语法(一)

    java基础语法(一) 1.类是一种抽象的概念,对象是类的一种具体表示形式,是具体的概念.先有类,然后由类来生成 对象(Object).对象又叫做实例(Instance). 2.类由两大部分构成:属性 ...

  9. 【JDK1.8】JUC——AbstractQueuedSynchronizer

    一.前言 在上一篇中,我们对LockSupport进行了阅读,因为它是实现我们今天要分析的AbstractQueuedSynchronizer(简称AQS)的基础,重新用一下最开始的图: 可以看到,在 ...

  10. 正确截取List指定位置的内容

    正确截取List指定位置的内容 import java.util.ArrayList; import java.util.List; public class ListUtils { public s ...