Chinaunix首页 | 论坛 | 博客
  • 博客访问: 260304
  • 博文数量: 78
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 852
  • 用 户 组: 普通用户
  • 注册时间: 2013-05-06 11:01
个人简介

不做第二个别人,永远做第一个自己。

文章分类

全部博文(78)

文章存档

2014年(60)

2013年(18)

分类: LINUX

2014-04-10 11:16:24

nginx 结合 perl

 
Configure Nginx to execute Perl script.
This example shows to use fcgiwrap + spawn-fcgi.  

安装一些辅助软件包!

# yum –enablerepo=epel -y install spawn-fcgi fcgi-devel 
# yum -y groupinstall "Development Tools" 
 
安装fcgiwrap 
# wget   -O fcgiwrap.tar.gz 
# tar zxvf fcgiwrap.tar.gz 
# cd gnosek-fcgiwrap-* 
gnosek-fcgiwrap-4b2151e]# autoreconf -i 
gnosek-fcgiwrap-4b2151e]# ./configure 
gnosek-fcgiwrap-4b2151e]# make 
gnosek-fcgiwrap-4b2151e]# make install 
install -d -m 755 /usr/local/sbin
install -m 755 fcgiwrap /usr/local/sbin
install -d -m 755 /usr/local/man/man8
install -m 644 fcgiwrap.8 /usr/local/man/man8
 
配置nginx
# vim  /etc/sysconfig/spawn-fcgi 
# 在最后添加
OPTIONS="-u nginx -g nginx -a 127.0.0.1 -p 9001 -P /var/run/spawn-fcgi.pid — /usr/local/sbin/fcgiwrap" 
# vim /etc/nginx/conf.d/default.conf 
# 在server部分添加
  location ~ \.pl|cgi$ {
        fastcgi_pass   127.0.0.1:9001;
        fastcgi_index  index.cgi;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        /etc/nginx/fastcgi_params;
    }
 这个看起来是不是和php的有点像呢??

/etc/rc.d/init.d/nginx restart

Stopping nginx: [ OK ]
Starting nginx: [ OK ]

# /etc/rc.d/init.d/spawn-fcgi start

Starting spawn-fcgi: [ OK ]

# chkconfig spawn-fcgi on 

创建一个cgi的脚本

# vim /usr/share/nginx/html/index.cgi 

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "\n\n";
print "
\n"; print "CGI Test Page"; print "\n
\n"; print " \n\n";
# chmod 705 /usr/share/nginx/html/index.cgi 、
测试访问路径:
阅读(442) | 评论(0) | 转发(0) |
0

上一篇:NGINX 基础认证

下一篇:NGINX + PHP 安装配置

给主人留下些什么吧!~~