【问题标题】:When executing CGI, give me only plain text执行 CGI 时,只给我纯文本
【发布时间】:2014-01-10 06:16:16
【问题描述】:

当我尝试执行 CGI 时,它只给我纯文本。

我用 apache2 安装了 PHP5.3.11 所有这些都是从源代码手动安装的,而不是从 apt-get

## Apache2
./configure --prefix/=usr/loca/apache2
make
make install

## php5
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs
make
make test
make install

以上是我用来安装apache2和php5的命令。 我猜我对 apache2 和 php5 的安装是正确的,因为我可以在我的服务器上运行 php 代码。所以我想在正确设置配置后尝试执行 CGI 脚本。 但是它只显示 CGI 脚本的纯文本。

###Start###

#!/usr/bin/perl -w
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";

for ($i=0; $i<10; $i++){
    print $i."<br />";
}

###End###

perl 已正确安装在 /usr/bin/perl。

我将我的 httpd.conf 设置如下。

<Directory "/usr/local/apache2/cgi-bin">
    Options +ExecCGI
    AddHandler cgi-script .cgi .pl
    Require all granted
</Directory>

我认为 cgi-php5 也已正确安装,因为当我执行“php-cgi -h”时,它会给我一个结果。 当我通过浏览器打开 phpinfo() 时, GATEWAY_INTERFACE 设置为 CGI/1.1

我缺少什么吗?感谢您的帮助。

【问题讨论】:

    标签: cgi


    【解决方案1】:

    我找到了答案。 我的错误是在 httpd.conf 上,这是一个非常愚蠢的错误。 :-(

    我不得不取消注释以下行。

    LoadModule cgi-script blahblah

    没有人知道我为这个愚蠢的错误花了多少小时:-(

    【讨论】:

      猜你喜欢
      • 2013-12-31
      • 2014-09-18
      • 1970-01-01
      • 2016-03-17
      • 1970-01-01
      • 1970-01-01
      • 2022-10-05
      • 2021-08-24
      • 2013-12-08
      相关资源
      最近更新 更多