Spawn-FCGI安装
来源:互联网 发布:炒白银实时数据 编辑:程序博客网 时间:2024/05/24 05:03
Spawn-FCGI安装
获取spawn-fcgi编译安装包, 在 http://redmine.lighttpd.net/projects/spawn-fcgi/wiki 上可
以获取当 前最新的版本。
tar -zxvf spawn-fcgi-x.x.x.tar.gz
cd spawn-fcgi-x.x.x.tar.gz
./configure。
make
sudo make install
如果遇到 以下错误:
如果遇到 以下错误:
<code class="hljs erlang has-numbering">. /autogen. sh: x: autoreconf: <span class="hljs-keyword">not</span> found</code><ul style="" class="pre-numbering"><li>1</li></ul>
因为没有安装automake 工具, ubuntu用 下面的命令安装好就可以了
<code class="hljs bash has-numbering"><span class="hljs-built_in">sudo</span> apt-get install autoconf automake libtool </code><ul style="" class="pre-numbering"><li>1</li></ul>
spawn-fcgi的帮 助信息可以通过man spawn-fcgi或spawn-fcgi –h获得, 下面是部分常用
spawn-fcgi参数信息:
Nginx与FastCGI
f 指定调用 FastCGI的进程的执行程序位置
- a 绑定到 地址addr。
- p 绑定到 端口 port。
- s 绑定到 unix domain socket
- C 指定产 生的FastCGI的进程数, 默认为 5。 ( 仅用 于PHP)
- P 指定产 生的进程的PID文件路径。
- F 指定产 生的FastCGI的进程数( C的CGI用 这个)
- u和- g FastCGI使用 什么 身 份( - u 用 户 - g 用 户 组) 运行,
CentOS下可以使用 apache用 户 , 其他的根据情况配置, 如nobody、 www- data等。
fastgci应 用 程序
使用 C/C++编写 fastcgi应 用 程序, 可以使用 FastCGI软件开发套件或者其它开发框架, 如
fastcgi++。
本文使用 FastCGI软件开发套件——fcgi
http://www.filewatcher.com/d/Gentoo/distfiles/Other/fcgi-2.4.1 -SNAP-
091 0052249.tar.gz.61 4929.html
通过此套件可以轻松编写 fastcgi应 用 程序, 安装fcgi:
. /configue
make
如果编译出 现类似以下错误:
6.3 Nginx与FastCGI
94
cgio. cpp: In destructor ’ virtual fcgi_streambuf: : ~fcgi_streambuf( ) ’ :
fcgio. cpp: 50: error: ’ EOF’ was not declared in this scope
fcgio. cpp: In member function ’ virtual int fcgi_streambuf: : overflow( int) ’ :
fcgio. cpp: 70: error: ’ EOF’ was not declared in this scope
fcgio. cpp: 75: error: ’ EOF’ was not declared in this scope
fcgio. cpp: In member function ’ virtual int fcgi_streambuf: : sync( ) ’ :
fcgio. cpp: 86: error: ’ EOF’ was not declared in this scope
fcgio. cpp: 87: error: ’ EOF’ was not declared in this scope
fcgio. cpp: In member function ’ virtual int fcgi_streambuf: : underflow( ) ’ :
fcgio. cpp: 113: error: ’ EOF’ was not declared in this scope
make[2] : * [fcgio. lo] Error 1
make[2] : Leaving directory /root/downloads/fcgi- 2. 4. 1- SNAP- 0910052249/libfcgi'
/root/downloads/fcgi- 2. 4. 1- SNAP- 0910052249’
make[1] : *** [all- recursive] Error 1
make[1] : Leaving directory
make: * [all] Error 2
解决办法:
<code class="hljs bash has-numbering"><span class="hljs-built_in">cd</span> include<span class="hljs-built_in">sudo</span> vi fcgio.h</code><ul style="" class="pre-numbering"><li>1</li><li>2</li></ul>
头文件添加
<code class="hljs vala has-numbering"><span class="hljs-preprocessor">#include <stdio.h></span></code><ul style="" class="pre-numbering"><li>1</li></ul>
再次运行
make
sudo make install
编写一个fcgi简单的应用程序:
fcgi_demo.c
<code class="hljs perl has-numbering"><span class="hljs-comment">#include <stdio. h></span><span class="hljs-comment">#include <stdlib. h></span><span class="hljs-comment">#include <string. h></span><span class="hljs-comment">#include <unistd. h></span><span class="hljs-comment">#include "fcgi_stdio. h"</span><span class="hljs-keyword">int</span> main( <span class="hljs-keyword">int</span> argc, char <span class="hljs-variable">*argv</span>[] ){<span class="hljs-keyword">int</span> count = <span class="hljs-number">0</span>;<span class="hljs-keyword">while</span> ( FCGI_Accept( ) >= <span class="hljs-number">0</span>) {<span class="hljs-keyword">printf</span>( <span class="hljs-string">"Content- type: text/html\r\n"</span>) ;<span class="hljs-keyword">printf</span>( <span class="hljs-string">"\r\n"</span>) ;<span class="hljs-keyword">printf</span>( <span class="hljs-string">"<title>Fast CGI Hello! </title>"</span>) ;<span class="hljs-keyword">printf</span>( <span class="hljs-string">"<h1>Fast CGI Hello! </h1>"</span>) ;<span class="hljs-keyword">printf</span>( <span class="hljs-string">"Request number <span class="hljs-variable">%d</span> running on host <i><span class="hljs-variable">%s</span></i>\n"</span>, ++count, getenv( <span class="hljs-string">"SERVER_NAME"</span>) ) ;}<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;}</code><ul style="" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li></ul>
*编译:
<code class="hljs lasso has-numbering">gcc fcgi_demo<span class="hljs-built_in">.</span>c <span class="hljs-attribute">-o</span> demo <span class="hljs-attribute">-lfcgi</span></code><ul style="" class="pre-numbering"><li>1</li></ul>
配置fastcgi.conf
<code class="hljs bash has-numbering"><span class="hljs-built_in">cd</span> usr/local/nginx/conf<span class="hljs-built_in">sudo</span> vi nginx.conf</code><ul style="" class="pre-numbering"><li>1</li><li>2</li></ul>
把下面代码复制到
nginx.conf文件里
<code class="hljs avrasm has-numbering">location /demo { fastcgi_pass <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>:<span class="hljs-number">9001</span><span class="hljs-comment">;</span> fastcgi_index demo<span class="hljs-preprocessor">.cgi</span><span class="hljs-comment">;</span> include fastcgi<span class="hljs-preprocessor">.conf</span><span class="hljs-comment">;</span> } location = /upload<span class="hljs-preprocessor">.cgi</span>{ root html<span class="hljs-comment">;</span> index upload<span class="hljs-preprocessor">.html</span><span class="hljs-comment">;</span> } location = /upload/UploadAction{ fastcgi_pass <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>:<span class="hljs-number">9002</span><span class="hljs-comment">;</span> fastcgi_index echo<span class="hljs-preprocessor">.cgi</span><span class="hljs-comment">;</span> include fastcgi<span class="hljs-preprocessor">.conf</span><span class="hljs-comment">;</span> }</code><ul style="" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li></ul>
将zyfile.tar.gz复制到
/usr/local/nginx/html
解压
<code class="hljs avrasm has-numbering">tar -zxvf zyfile<span class="hljs-preprocessor">.tar</span><span class="hljs-preprocessor">.gz</span>cd zyfile<span class="hljs-preprocessor">.tar</span><span class="hljs-preprocessor">.gz</span>./configuremakesudo make install</code><ul style="" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul>
然后将demo.html改名为upload.html
<code class="hljs avrasm has-numbering">sudo mv demo<span class="hljs-preprocessor">.html</span> upload<span class="hljs-preprocessor">.html</span></code><ul style="" class="pre-numbering"><li>1</li></ul>
并把所有文件包括文件夹移动到
/usr/local/nginx/html目录下
<code class="hljs ruby has-numbering">sudo mv * <span class="hljs-regexp">/usr/local</span><span class="hljs-regexp">/nginx/html</span></code><ul style="" class="pre-numbering"><li>1</li></ul>
会根据配置好的文件,去/usr/local/nginx/html目录下寻找zy工具。如果目录下没有移动过来的文件,则会出现404错误。
依次运行
<code class="hljs lasso has-numbering">spawn<span class="hljs-attribute">-fcgi</span> <span class="hljs-attribute">-a</span> <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> <span class="hljs-attribute">-p</span> <span class="hljs-number">9001</span> <span class="hljs-attribute">-f</span> <span class="hljs-built_in">.</span>/test/echospawn<span class="hljs-attribute">-fcgi</span> <span class="hljs-attribute">-a</span> <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> <span class="hljs-attribute">-p</span> <span class="hljs-number">9002</span> <span class="hljs-attribute">-f</span> <span class="hljs-built_in">.</span>/test/echo</code><ul style="" class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul>
出现两次PID= xxxxx则成功
重启nginx
<code class="hljs bash has-numbering"><span class="hljs-built_in">sudo</span> /usr/local/nginx/sbin/ <span class="hljs-operator">-s</span> reload</code><ul style="" class="pre-numbering"><li>1</li></ul>
打开浏览器,输入ip地址192.168.21.128/upload.html
出现上传界面
选择文件,上传成功!
系统重启,需进行以下步骤操作:
进入git
<code class="hljs go has-numbering"><span class="hljs-built_in">make</span> clean<span class="hljs-built_in">make</span></code><ul style="" class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul>
依次运行
<code class="hljs lasso has-numbering">spawn<span class="hljs-attribute">-fcgi</span> <span class="hljs-attribute">-a</span> <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> <span class="hljs-attribute">-p</span> <span class="hljs-number">9001</span> <span class="hljs-attribute">-f</span> <span class="hljs-built_in">.</span>/test/echospawn<span class="hljs-attribute">-fcgi</span> <span class="hljs-attribute">-a</span> <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> <span class="hljs-attribute">-p</span> <span class="hljs-number">9002</span> <span class="hljs-attribute">-f</span> <span class="hljs-built_in">.</span>/test/echo</code><ul style="" class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul>
出现两次PID= xxxxx则成功
重启nginx
<code class="hljs bash has-numbering"><span class="hljs-built_in">sudo</span> /usr/local/nginx/sbin/ <span class="hljs-operator">-s</span> reload</code><ul style="" class="pre-numbering"><li>1</li></ul>
打开浏览器,输入ip地址192.168.21.128/upload.html
出现上传界面
选择文件,上传成功!
- nginx+spawn-fcgi安装
- Spawn-FCGI安装
- Spawn-FCGI安装
- linux spawn-fcgi安装
- Ubuntu 10.10下安装nginx + fastcgi + spawn-fcgi + mysql
- Debian/Ubuntu里安装Nginx+PHP(spawn-fcgi)+MySQL
- ubuntu 9.10 安装nginx + fastcgi + spawn-fcgi +mysql 日记
- buntu 9.10 安装nginx + fastcgi + spawn-fcgi +mysql
- Debian/Ubuntu里安装Nginx+PHP(spawn-fcgi)+MySQL
- spawn-fcgi工作原理
- 修改编译spawn-fcgi
- spawn-fcgi运行fcgiwrap
- spawn-fcgi 代码介绍
- spawn-fcgi启动
- spawn-fcgi 源码分析
- spawn-fcgi运行fcgiwrap
- install spawn-fcgi
- spawn-fcgi与fcgi的运行机制分析
- unbuntu安装eclipse编写c程序出现launch failed.Binary not found
- hadoop MapReduce程序中解决第三方jar包问题
- boa:Hello CGI
- android开发环境安装(Eclipse)出现的几个问题
- LeetCode 11. Container With Most Water
- Spawn-FCGI安装
- Express框架详解
- gulp 静态资源打包 压缩 合并
- Normalize vs Reset
- 【java】华容道游戏设计与搜索算法实现
- 数组输出商品价格
- Eclipse中查看jar包中的源码
- 各种排序算法时空复杂度分析
- 《React-Native系列》27、 Redux的异步数据流