Debian Lenny 上 Apache 2.2 下的 Perl CGI 或 CGI::Fast

发布于 2024-10-08 12:28:56 字数 1522 浏览 3 评论 0原文

我在 Debian Lenny 机器上有 2 个不同的 Web 服务器。一台运行 FastCGI (TRAC),另一台 Web 服务器运行 PHP 和一些 CGI 脚本。所以我目前启用了 2 个 Apache2 模块(cgi 和 fcgi)并相应地设置了 2 个虚拟主机。我对同时运行的这两个模块没有其他特别的兴趣。

所以我只想让 Apache fastcgi 模块保持运行,因为它看起来是更高效的模块。

请您确认以下评估是否正确?
1- 我不会对 TRAC 站点进行任何操作/更改(已经运行 fcgi)
2-我必须调整其他 Web 服务器虚拟主机,以使用 fastcgi 脚本的处理程序进行设置
3-我只需将 Perl 模块从“使用 CGI”更改为“使用 CGI::Fast”
4-我将能够保留其余的 Perl 现有 CGI 脚本,无需进行其他更改
5-我不需要在Web服务器脚本中使用CGI::Apache,而是使用CGI::FastCGI(i/o当前的CGI模块)

我希望我的观点很清楚,因为这对我来说有点陌生......

Thx

<强>编辑:
感谢 Naveed 和 J-16 的提示,
如果它可以帮助其他人,我所做的就是让它工作:

  • 嗯,用 CPAN 安装了 CGI::Fast,然后它工作得更好..
    在已安装 libperl 的 Debian 上

    perl -MCPAN -e shell
    cpan>安装 CGI::快速
    
  • 将文件名从 *.cgi 更改为 *.fcgi,

  • 包括按照 Naveed 下面建议的 fastcgi while 循环,
  • 设置相关的 apache具有正确的 fastcgi 处理程序的虚拟主机(请参阅 fastcgi 文档
  • 启用了 Apache fastcgi 模块(a2enmod fastcgi)并禁用cgi模块,
  • 检查Apache设置中的fastcgi.conf文件,
  • 重新启动Apache,
  • 检查作为Apache子进程运行的fastcgi(ps -afx),
  • 修复了一些脚本问题,已经在..但新运行 fastcgi 时出现,按照建议(通过检查 Apache 日志检测到错误),
  • 编辑:调整文件上传代码,因为初始脚本不再工作(仍然不明白为什么) ,所以我必须用这样的循环替换 while 循环:

    open(FILE,">$upload_dir/$file_name")
    while ($bytes_count = read($file_query,$buffer,2096)) {
    $size += $bytes_count;
    打印文件$缓冲区;
    }
    关闭(文件);
    
  • 完成。

世界尚不完美,但它终于运转起来了。

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::Apache but CGI::FastCGI (i/o the current CGI module) in the web server scripts

I 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 installed

    perl -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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

快乐很简单 2024-10-15 12:28:56

您需要做的不仅仅是将 use CGI 更改为 use CGI::Fast。确保使用 while 循环包装 CGI 脚本,如文档所述 http://p3rl.org/CGI: :快

use CGI::Fast;
while (CGI::Fast->new()) {
    # The original CGI code goes in here
}

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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文