nginx FastCGI 安装配置

yum install epel-release
yum install fcgi-devel //安装fastcgi库 
请去 : https://github.com/gnosek/fcgiwrap 下载 fcgiwrap
tar zxf fcgiwrap-1.0.3.tar.gz
cd fcgiwrap-1.0.3
autoreconf -i
./configure
make
make install
安装完毕.开始运行该软件
默认安装路径 /usr/local/sbin
之后三个选项
# fcgiwrap -h
Usage: fcgiwrap [OPTION]
Invokes CGI scripts as FCGI.
fcgiwrap version 1.0.1
Options are:
-c <number> Number of processes to prefork
-s <socket_url> Socket to bind to (say -s help for help)
-h Show this help message and exit
# TCP 启动方式
# /usr/local/bin/fcgiwrap -s tcp:127.0.0.1:8999
# 参数 n 为进程数量
# /usr/local/bin/fcgiwrap -c 8 -s tcp:127.0.0.1:8999
# SOCK启动方式
# /usr/local/bin/fcgiwrap -s unix:/tmp/perl-fpm.sock
# chmod +x /tmp/perl-fpm.sock
# sock 关闭方式
# killall fcgiwrap
# rm -f /tmp/perl-fpm.sock
# 编辑nginx 配置文件
# 在server里加入如下 该站点即可支持pl perl cgi 三个后缀
location /cgi-bin/ {
#fastcgi_pass unix:/tmp/perl-fpm.sock;
fastcgi_pass 127.0.0.1:8999;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
在网站根目录下创建 cgi-bin目录
mkdir cgi-bin
 
测试hello.c
 
Vim hello.c
 
 
 
#include<stdio.h>
 
int main(){
 
printf("Content-Type:text/html\n\n");
printf("hello!!");
 
 
}
 
gcc hello.c –o hello
测试
 
# 测试的 hello world 文件
vi 1.pl
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, world.";
# 一定要记得给执行权限
chmod +x 1.pl
 
 

猜你喜欢

转载自blog.csdn.net/abc595951988/article/details/71429852