spawn-fcgi运行fcgiwrap
http://linuxjcq.blog.51cto.com/3042600/718002
1. 下载spawn-fcgi并安装
- http://download.lighttpd.net/spawn-fcgi/releases-1.6.x/spawn-fcgi-1.6.3.tar.gz -P /usr/local/src
- tar zxvf /usr/local/src/spawn-fcgi-1.6.3.tar.gz -P /usr/local/src
- cd /usr/local/src/spawn-fcgi-1.6.3
- ./configure
- make
- # 复制spawn-fcgi到/usr/local/bin/
- cp spawn-fcgi /usr/local/bin
2. 下载并安装fcgi库
- wget http://fastcgi.com/dist/fcgi-2.4.0.tar.gz -P /usr/local/src
- tar zxvf /usr/local/src/fcgi-2.4.0.tar.gz -C /usr/ocal/src
- cd /usr/local/src/fcgi-2.4.0
- ./configure
- make
- make install
编译过程有报错
- error: 'EOF' was not declared in this scope
解决办法:在include/fcgio.h文件中加上#include <cstdio>
- vi include/fcgio.h
- #include <iostream>
- # 添加下行
- #include <cstdio>
3. 安装fcgiwrap
- wget https://download.github.com/gnosek-fcgiwrap-1.0.3-4-g58ec209.tar.gz -P /usr/locl/src
- tar zxvf /usr/local/src/gnosek-fcgiwrap-1.0.3-4-g58ec209.tar.gz -P /usr/local/src
- cd /usr/local/src/gnosek-fcgiwrap-58ec209
- autoreconf -i
- export ac_cv_func_malloc_0_nonnull=yes
- ./configure
- make
- # 复制fcgiwrap
- cp fcgiwrap /usr/local/bin
4. 创建启动和管理脚本
- vi /etc/rc.d/init.d/cfcgi
- #!/bin/bash
- # cfcgi – this script starts and stops the fcgiwrap instance
- #
- # chkconfig: – 96 28
- # description: cfcgi
- # processname: cfcgi
- RETVAL=0
- case "$1" in
- start)
- echo "Starting fastcgi"
- /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
- RETVAL=$?
- ;;
- stop)
- echo "Stopping fastcgi"
- killall -9 fcgiwrap
- RETVAL=$?
- ;;
- restart)
- echo "Restarting fastcgi"
- killall -9 fcgiwrap
- /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
- RETVAL=$?
- ;;
- *)
- echo "Usage: c-fastcgi {start|stop|restart}"
- exit 1
- ;;
- esac
- exit $RETVAL
这个脚本是salogs.com中的,直接拿来用了
添加为服务
- chmod 0755 /etc/rc.d/init.d/cfcgi
- chown root:root /etc/rc.d/init.d/cfcgi
- chkconfig –add cfcgi
- chkconfig cfcgi on
5. 启动
- service cfcgi start
检验下:
- netstat -tlnp | grep "fcgiwrap"
- tcp 0 0 192.168.1.10:10000 0.0.0.0:* LISTEN 4021/fcgiwrap
- ps -ef | grep "fcgi"
- nobody 4021 1 0 18:34 ? 00:00:00 /usr/local/bin/fcgiwrap
注意配置文件中是以nobody身份运行的
6. 配置nginx
- location ~ .*\.cgi$
- {
- fastcgi_pass 192.168.1.10:10000;
- include fcgi.conf;
- }
配置文件fcgi.conf和php公用为:
- vi fcgi.conf
- fastcgi_param GATEWAY_INTERFACE CGI/1.1;
- fastcgi_param SERVER_SOFTWARE nginx;
- 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_FILENAME $document_root$fastcgi_script_name;
- 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 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;
- # PHP only, required if PHP was built with –enable-force-cgi-redirect
- 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的更多相关文章
- lighttpd与fastcgi+cgilua原理、代码分析与安装
原理 http://www.cnblogs.com/skynet/p/4173450.html 快速通用网关接口(Fast Common Gateway Interface/FastCGI)是通用网关 ...
- Nginx系列2之Nginx+php
preface 公司所有的大多数业务都泡在LNMP平台上,所以对PHP+Nginx有点了解,那么就做个小小的总结吧. what's FastCGi FastCGI是一个可伸缩,高速的在HTTP ser ...
- Python—进程、线程、协程
一.线程 线程是操作系统能够进行运算调度的最小单位.它被包含在进程之中,是进程中的实际运作单位.一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行不同的任务 方法: ...
- nodeJS 菜鸟入门
从一个简单的 HTTP 服务开始旅程-- 创建一个 server.js 文件,写入: //最简单的 http 服务例子 var http = require("http"); ht ...
- python三大神器之一fabric使用
fabric 是一个python包 是一个基于ssh的部署工具包 通常用来对网站 微服务等等的批量部署 例如 我有5台线上服务器 可以通过一台对着5台分发,实现自动部署的目的. 简单介绍下 fabri ...
- python---协程 学习笔记
协程 协程又称为微线程,协程是一种用户态的轻量级线程 协程拥有自己的寄存器和栈.协程调度切换的时候,将寄存器上下文和栈都保存到其他地方,在切换回来的时候,恢复到先前保存的寄存器上下文和栈,因此:协程能 ...
- nodejs(二)child_process模块
1.child_process是Node.js的一个十分重要的模块,通过它可以实现创建多进程,以利用多核计算资源. child_process模块提供了四个创建子进程的函数,分别是spawn,exec ...
- Node.js进程通信模块child_process
前言 Node.js是一种单线程的编程模型,对Node.js的赞美和诟病的也都是因为它的单线程模型,所有的任务都在一个线程中完成(I/O等例外).单线程模型,不仅让代码非常简洁,更是直接避免了线程调度 ...
- python_线程、进程和协程
线程 Threading用于提供线程相关的操作,线程是应用程序中工作的最小单元. #!/usr/bin/env python #coding=utf-8 __author__ = 'yinjia' i ...
随机推荐
- iOS监听模式系列之本地通知Notification
本地通知 本地通知是由本地应用触发的,它是基于时间行为的一种通知形式,例如闹钟定时.待办事项提醒,又或者一个应用在一段时候后不使用通常会提示用户使用此应用等都是本地通知.创建一个本地通知通常分为以下几 ...
- 棋盘的完美覆盖问题,c++代码实现
#include "stdafx.h" #include<iostream> #include<iomanip> using namespace std; ...
- seo建站需要注意哪些
seo建站是搜索引擎优化的意思,通过seo建站技术,我们可以为站点带来可观的流量.那么,要怎样才能做好seo建站?seo建站优化过程中应该注意的事项有哪些?这些问题,是每一个站长都关心的.鉴于此,笔者 ...
- jquery 加法 乘法运算 精确计算函数
int类型相加不会出现问题,但小数点相加就会出现问题 //乘法函数 var accMul = function(arg1, arg2){ var m=0,s1=arg1.toString(),s2=a ...
- JQuery(一)---- JQ的选择器,属性,节点,样式,函数等操作详解
JQuery的基本概念 JQuery是一个javascript库,JQuery凭借着简洁的语法和跨平台的兼容性,极大的简化了js操作DOM.处理事件.执行动画等操作.JQuery强调的理念是:'wri ...
- 简单poi创建execl
Workbook workbook = new HSSFWorkbook();// 创建一个Excel文件 Workbook workbook = new XSSFWorkbook();// 创建一个 ...
- JFace dailog button事件中刷新透视图异常 Trying to execute the disabled command org.eclipse.ui.window.closePerspective
报错的代码为 protected void buttonPressed(int buttonId) { Display.getDefault().syncExec(new Runnable() { p ...
- List内存分配
当采用默认构造函数List<int> value = new List<int>();实例化一个List<T>对象时,.Net Framework只是在内存中申请了 ...
- python抽象类+抽象方法实现接口(interface)
#python没有类似于java和C#的接口类(interface),需要使用抽象类 和抽象方法来实现接口功能 #!/usr/bin/env python#_*_ coding:utf-8 _*_ f ...
- 第一次作业 orm环境构建(hibernate)及基本的demo
一.数据库 1.创建数据库hibernate01-1514010311 2.创建表 customer CREATE TABLE customer( id int(11) not null auto_i ...