1. Install FCGI Module # wgethttp: plugin # cdFCGI-0.70 # perlMakefile. PL # make # makeinstall2. install IO and IO: ALL Module # wgethttp: search. cpan. orgCPANa
1. Install the FCGI Module
# Wget http: // search.CpAn.org/CPAN/authors/Id/B/BO/BOBTFISH/FCGI-0.70.tar.gz
# Tar zxvf FCGI-0.70.tar.gz
#CdFCGI-0.70
# Perl MakeFile. PL
# Make
# Make install
2. Install IO and IO: ALL Module
# Wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/IO-1.25.tar.gz
# Tar zxvf IO-1.25.tar.gz
# Cd IO-1.25
# Perl Makefile. PL
# Make
# Make install
# Wget http://search.cpan.org/CPAN/authors/id/ I /IN/INGY/IO-All-0.41.tar.gz
# Tar zxvf IO-All-0.41.tar.gz
# Cd IO-All
# Perl Makefile. PL
# Make
# Make install
3. Perl script
Download the Perl script
See the end of this Article
I put this script in/usr/local/nginx/perl-fcgi.pl
#Chmod755/usr/local/nginx/perl-fcgi.pl
4. cgi start/stop script (the nobody is the nginx running user)
# Vi/usr/local/nginx/start_perl_cgi.sh
#!/bin/bash#set -xdir=/usr/local/nginxstop (){#pkill -f $dir/perl-fcgi.plkill $(cat $dir/logs/perl-fcgi.pid)rm $dir/logs/perl-fcgi.pid 2>/dev/nullrm $dir/logs/perl-fcgi.sock 2>/dev/nullecho "stop perl-fcgi done"}start (){rm $dir/now_start_perl_fcgi.sh 2>/dev/nullchown nobody.root $dir/logsecho "$dir/perl-fcgi.pl -l $dir/logs/perl-fcgi.log -pid $dir/logs/perl-fcgi.pid -S $dir/logs/perl-fcgi.sock" >>$dir/now_start_perl_fcgi.shchown nobody.nobody $dir/now_start_perl_fcgi.shchmod u+x $dir/now_start_perl_fcgi.shsudo -u nobody $dir/now_start_perl_fcgi.shecho "start perl-fcgi done"}case $1 instop)stop;;start)start;;restart)stopstart;;esac
# Chmod 755/usr/local/nginx/start_perl_cgi.sh
# Startup Script
#/Usr/local/nginx/start_perl_cgi.sh start
Under normal circumstances in the/usr/local/nginx/logs to generate the perl-fcgi.sock file, if not generated, it is necessary to check the above steps together.
5. Configure nginx
server { listen 80; server_name _; location / { root /usr/local/nginx/html; index index.html index.htm index.cgi; } location ~ .*\.(pl|cgi)?$ { gzip off; root /data/nginx/html; fastcgi_pass unix:/usr/local/nginx/logs/perl-fcgi.sock; fastcgi_index index.cgi; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_read_timeout 60; }}
6. Perl probe test
Download Related Files
Perl probe and Perl script:
Free onHttp://linux.linuxidc.com/
Both the user name and password areWww.linuxidc.com
The specific download directory is in/Pub/2011/09/27/Nginx fastcgi perl (pl, cgi) Support/