0 Comments

Perl(FastCGI)的安装

发布于:2013-03-05  |   作者:广州网站建设  |   已聚集:人围观
Perl(FastCGI)的安装

1.获取wrapper程序

读者可以从http://www.nginx.eu/nginx-fcgi/ 上下载nginx-fcgi.txt文件,然后将其命名为nginx-fcgi.pl,并放到/usr/local/nginx目录下。nginx-fcgi.pl是一个用Perl脚本写的wrapper实例,所以,操作系统必须要安装Perl程序以及相关模块。

2.安装相关的系统支持模块

可以从http://search.cpan.org下载所需的相应模块,然后进行安装。

(1)安装FCGI模块


  1. [root@localhost opt]# tar zxvf FCGI-0.71.tar.gz  
  2. [root@localhost opt]# cd FCGI-0.71  
  3. [root@localhost FCGI-0.71]# perl Makefile.PL  
  4. [root@localhost FCGI-0.71]# make  
  5. [root@localhost FCGI-0.71]# make install 

 

(2)安装IO模块

  1. [root@localhost opt]# tar -xvzf IO-1.25.tar.gz  
  2. [root@localhost opt]# cd IO-1.25  
  3. [root@localhost IO-1.25]# perl Makefile.PL  
  4. [root@localhost IO-1.25]# make  
  5. [root@localhost IO-1.25]# make install 

广州网站建设,网站建设,广州网页设计,广州网站设计

(3)安装IO-ALL模块

  1. [root@localhost opt]# tar -xvzf IO-All-0.39.tar.gz  
  2. [root@localhost opt]# cd IO-ALL-0.39  
  3. [root@localhost IO-ALL-0.39]# perl Makefile.PL  
  4. [root@localhost IO-ALL-0.39]#make  
  5. [root@localhost IO-ALL-0.39]#make install 

3.编写nginx-fcgi启动脚本

仅仅有wrapper文件是不够的,还需要一个脚本来创建socket、启动wrapper以及将wrapper和socket绑定。下面通过一个shell脚本来完成这一系列工作。


  1. [root@localhost root]# more nginx-fcgi  
  2. #!/bin/bash  
  3. nginxroot=/usr/local/nginx  
  4.  
  5. start ()  
  6. {  
  7. chown nobody.root $nginxroot/logs  
  8. echo "$nginxroot/nginx-fcgi.pl -l $nginxroot/ logs/nginx-fcgi.log -pid $nginxroot/logs/nginx- fcgi.pid  -S  $nginxroot/logs/nginx-fcgi.sock" >>$nginxroot/nginx_fcgi.sh  
  9. chown nobody.nobody $nginxroot/nginx_fcgi.sh  
  10. chmod 755 $nginxroot/nginx_fcgi.sh  
  11. sudo -u nobody $nginxroot/nginx_fcgi.sh  
  12. echo "start nginx-fcgi done"  
  13. }  
  14.  
  15. stop ()  
  16. {  
  17. kill $(cat $nginxroot/logs/nginx-fcgi.pid)  
  18. rm $nginxroot/logs/nginx-fcgi.pid 2>/dev/null  
  19. rm $nginxroot/logs/nginx-fcgi.sock 2>/dev/null  
  20. rm $nginxroot/nginx_fcgi.sh 2>/dev/null  
  21. echo "stop nginx-fcgi done"  
  22. }  
  23.  
  24. case $1 in  
  25. stop)  
  26. stop  
  27. ;;  
  28.  
  29. start)  
  30. start  
  31. ;;  
  32.  
  33. restart)  
  34. stop  
  35. start  
  36. ;;  
  37.  
  38. *)  
  39. echo $"Usage: perl-cgi {start|stop|restart}"  
  40.        exit 1  
  41. esac 

在nginx-fcgi中,变量nginxroot用于指定Nginx的安装目录,nginx-fcgi.sock是生成的文件sock, nobody为运行nginx_fcgi进程的用户,这个用户要和运行Nginx的用户一致。

配置完脚本后,将此文件放到/usr/local/nginx目录下,接着通过如下方式管理nginx-fcgi进程:

广州网站建设,网站建设,广州网页设计,广州网站设计
  1. [root@localhost root]#chmod 755 /usr/local/nginx/nginx-fcgi.pl  
  2. [root@localhost root]#chmod 755 /usr/local/nginx/nginx-fcgi  
  3. [root@localhost root]#/usr/local/nginx/nginx-fcgi start|stop|restart 
标签:
飞机