Perl CGI or CGI::Fast under Apache 2.2 on Debian Lenny
I have 2 different web servers on a Debian Lenny machine. One is running FastCGI (TRAC) and the other web server is running PHP and some CGI scripts. So I have currently the 2 Apache2 modules enabled (cgi and fcgi) and the 2 vhosts setup accordingly. I have no other particular interest for these both modules running at the same time.
So I want to keep ONLY Apache fastcgi module running as it looks to be the more efficient one.
Could you pls confirm the following assessments to be right or correct ?
1- I will have nothing to do/change for the TRAC site (already running fcgi) 2- I will have to tune the other web server vhost to be set with an handler to fastcgi scripts 3- I will have to change only the perl modules from "use CGI" to "use CGI::Fast" 4- I will be able to keep the rest of the perl existing CGI scripts w/o other changes 5- I do not need to use CGI::Ap开发者_运维问答ache but CGI::FastCGI (i/o the current CGI module) in the web server scriptsI hope my point is clear as it's all a bit foreign to me ...
Thx
EDIT:
thx for the hints to Naveed and J-16, Here is what I did to get it working if it can help others :hum, installed CGI::Fast with CPAN, then it works better..
On Debian with libperl already installedperl -MCPAN -e shell cpan> install CGI::Fast
changed filename from *.cgi to *.fcgi,
- included the fastcgi while loop as adviced below by Naveed,
- setup the apache concerned vhost with the right handler for fastcgi (See fastcgi doc)
- enabled the Apache fastcgi module (a2enmod fastcgi) and disabled the cgi module,
- checked the fastcgi.conf file in the Apache settings,
- restarted Apache,
- checked the fastcgi running as an Apache sub process (ps -afx),
- fixed some script issues, already in.. but newly appearing when running fastcgi, as adviced (errors detected by checking the Apache logs),
EDIT: adapted the file upload code as the initial script did not work anymore (still don't understand why), so I had to replace the while loop by a such one:
open(FILE,">$upload_dir/$file_name") while ($bytes_count = read($file_query,$buffer,2096)) { $size += $bytes_count; print FILE $buffer; } close(FILE);
done.
World is not yet perfect but it finally works.
You will have to do a little more than just change use CGI to use CGI::Fast. Make sure you wrap you CGI scripts with a while loop, as the documentation states http://p3rl.org/CGI::Fast
use CGI::Fast;
while (CGI::Fast->new()) {
# The original CGI code goes in here
}
精彩评论