首页 > Linux系统 > system > centos 5.x系统编译perl环境让nginx支持cgi全过程
2011
09-23

centos 5.x系统编译perl环境让nginx支持cgi全过程

1.安装程序以前先查看一下你的系统有没有自带perl,执行perl -V 出现以下文字就表示你的系统带了perl

[root@host downloads]# perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.6.18-53.el5, archname=i386-linux-thread-multi
    uname='linux builder10.centos.org 2.6.18-53.el5 #1 smp mon nov 12 02:14:55 est 2007 i686 athlon i386 gnulinux '
    config_args='-des -Doptimize=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Dversion=5.8.8 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux-thread-multi -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dinc_version_list=5.8.7 5.8.6 5.8.5 -Dscriptdir=/usr/bin'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='4.1.2 20080704 (Red Hat 4.1.2-50)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.5.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
                        PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES
                        USE_PERLIO USE_REENTRANT_API
  Built under linux
  Compiled at Jun 13 2011 05:55:27
  @INC:
    /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/5.8.8

2.下载需要安装的源码包(在ssh工具里一次性执行以下代码)

wget -c http://file.xsdou.com/file/cgiwrap-fcgi.pl
wget -c http://file.xsdou.com/file/FCGI-0.73.tar.gz
wget -c http://file.xsdou.com/file/FCGI-ProcManager-0.19.tar.gz
wget -c http://file.xsdou.com/file/IO-All-0.43.tar.gz
wget -c http://file.xsdou.com/file/IO-1.25.tar.gz
wget -c http://file.xsdou.com/file/cgi-info.tar.gz

3.建立prel-fastcgi接口启动文件目录和perl站点目录(在ssh工具里一次性执行以下代码)

mkdir -p /usr/local/webserver/cgi
mkdir -p /wwwroot/htdocs/www/cgi-bin

4.编译安装FCGI-ProcManager-0.19(在ssh工具里一次性执行以下代码)

cd /tmp/downloads
tar zxvf FCGI-ProcManager-0.19.tar.gz
cd FCGI-ProcManager-0.19
perl Makefile.PL
make
make install

编译安装FCGI-0.73(在ssh工具里一次性执行以下代码)

cd /tmp/downloads
tar zxvf FCGI-0.73.tar.gz
cd FCGI-0.73
perl Makefile.PL
make
make install

6.编译安装IO-1.25(在ssh工具里一次性执行以下代码)

cd /tmp/downloads
tar zxvf IO-1.25.tar.gz
cd IO-1.25
perl Makefile.PL
make
make install

7.编译安装IO-All-0.43(在ssh工具里一次性执行以下代码)

cd /tmp/downloads
tar zxvf IO-All-0.43.tar.gz
cd IO-All-0.43
perl Makefile.PL
make
make install

复制fastcgi启动脚本到目录并赋予执行权限(在ssh工具里一次性执行以下代码)

cd /tmp/downloads
mv cgiwrap-fcgi.pl /usr/local/webserver/cgi
chmod +x /usr/local/webserver/cgi/cgiwrap-fcgi.pl

9.把perl测试文件复制到站点目录的cgi-bin目录下,并赋予777权限(在ssh工具里一次性执行以下代码)

cd /tmp/downloads
tar zxvf cgi-info.tar.gz
cd cgi-info
mv index.cgi /wwwroot/htdocs/www/cgi-bin/
chmod -R 777 /wwwroot/htdocs/www/cgi-bin/

10.建立perl开机启动(在ssh工具里一次性执行以下代码)

cat >> /etc/rc.local << EOF
/usr/local/webserver/cgi/cgiwrap-fcgi.pl > /dev/null 2>&1 &
EOF

11.启动perl的fastcgi脚本文件(在ssh工具里一次性执行以下代码)

/usr/local/webserver/cgi/cgiwrap-fcgi.pl > /dev/null 2>&1 &

12.执行netstat -lnp命令检查一下cgiwrap-fcgi.pl文件是否正常启动,如果有以下内容就表示启动成功


tcp        0      0 127.0.0.1:8999              0.0.0.0:*                   LISTEN      27543/perl-fcgi-pm

13.nginx配置文件设置

server
       {
               listen       80;
               server_name  perl.linuxtone.org;
               index index.html index.pl index.perl index.cgi;
               root /data/www/wwwroot/perl;
 
               location ~ .*\.(pl|perl|cgi)?$
               {
                       fastcgi_pass 127.0.0.1:8999;
                       fastcgi_index index.cgi;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include   fastcgi_params;
               } 
     }

14.至此32位centos 5.x下的perl(cgi)环境编译完成,至于怎么和kangle整合,看4楼详细介绍
centos 5.x系统编译perl环境让nginx支持cgi全过程 - 第1张  | 大博辞

最后编辑:
作者:admin
捐 赠如果您觉得这篇文章有用处,请支持作者!鼓励作者写出更好更多的文章!

留下一个回复