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 ...
随机推荐
- Linux 系统应用编程——线程基础
传统多任务操作系统中一个可以独立调度的任务(或称之为顺序执行流)是一个进程.每个程序加载到内存后只可以唯一地对应创建一个顺序执行流,即传统意义的进程.每个进程的全部系统资源是私有的,如虚拟地址空间,文 ...
- LeetCode(64)- Min Stack
题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time ...
- leetCode之旅(12)-反转二叉树
背景描述 Homebrew 是 OS X 平台上的包管理工具.用其官网的话说就是: the missing package manager for OS X | OS X 平台遗失的包管理器. 相信在 ...
- 和菜鸟一起学linux之linux性能分析工具oprofile移植
一.内核编译选项 make menuconfig General setup---> [*] Profiling support <*> OProfile system profil ...
- Day2_and_Day3 文件操作
文件修改操作: 文件的修改操作:文件并没有修改操作,实际是将一个编写的新文件覆盖了原有的文件 替换文件中的某个内容: with open('old.txt','r',encoding='utf-8') ...
- Sublime text 3 注册码激活码 版本号3143
—– BEGIN LICENSE —– TwitterInc 200 User License EA7E-890007 1D77F72E 390CDD93 4DCBA022 FAF60790 61AA ...
- Ocelot中文文档-委托处理程序
Ocelot允许用户将委托处理程序添加到HttpClient传输中. 这个功能在github #208中提出,我确定它会以各种方式被使用.之后我们在GitHub#264中进行了扩展. 用法 为了将委托 ...
- 简单而强大的bitset
简单而强大的bitset 介绍 有些程序需要处理二进制有序集,标准库提供了bitset 类型,事实上,bitset 是一个二进制容器,容器中每一个元素都是一位二进制码,或为 0,或为 1. 基础 bi ...
- tensorflow1.0.0 弃用了几个operator写法
除法和取模运算符(/, //, %)现已匹配 Python(flooring)语义.这也适用于 tf.div 和 tf.mod.为了获取强制的基于整数截断的行为,你可以使用 tf.truncatedi ...
- tomcat7性能调优与配置(以windows版为例)
一.配置tomcat服务状态查看帐号(E:\Tomcats\apache-tomcat-7.0.73Test\conf下面的tomcat-users.xml中)加入:<user username ...