php-imap_open产生500个内部服务器错误&;/etc/httpd/conf.d/文件夹中没有fcgid.conf文件

php-imap_open产生500个内部服务器错误&;/etc/httpd/conf.d/文件夹中没有fcgid.conf文件,php,apache,Php,Apache,我正在使用下面的脚本从名为this.php的php访问我的gmail 我也已经登记了 我已经确认opensll和imap扩展已加载到Apache中 我已确认该文件的文件权限 在apache日志中,我得到的唯一错误是 [Tue Jun 17 23:42:12 2014] [warn] [client 24.120.116.118] mod_fcgid: read data timeout in 40 seconds [Tue Jun 17 23:42:12 2014] [error] [clien

我正在使用下面的脚本从名为
this.php的php访问我的gmail

我也已经登记了

我已经确认opensll和imap扩展已加载到Apache中

我已确认该文件的文件权限

在apache日志中,我得到的唯一错误是

[Tue Jun 17 23:42:12 2014] [warn] [client 24.120.116.118] mod_fcgid: read data timeout in 40 seconds
[Tue Jun 17 23:42:12 2014] [error] [client 24.120.116.118] Premature end of script headers: this.php
[Tue Jun 17 23:42:12 2014] [error] [client 24.120.116.118] File does not exist: /home/cesarbi1/public_html/500.shtml
不管怎样,我都能拿到500分。如果我用
imap\u open
注释掉该行,则该页面不会显示

是否有其他地方可以查找错误?或者有人能告诉我我的剧本有什么问题吗

<?php
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'username@gmail.com';
$password = 'password';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to your email account: ' . imap_last_error());

/* grab emails */
$emails = imap_search($inbox,'UNSEEN') or die('Cannot connect to your email account: ' . imap_last_error());

/* if emails are returned, cycle through each... */
if($emails) {

    /* begin output var */
    $output = '';

    /* put the newest emails on top */
    rsort($emails);

    /* for every email... */
    foreach($emails as $email_number) {

        /* get information specific to this email */
        $overview = imap_fetch_overview($inbox,$email_number,0);
        $message = imap_fetchbody($inbox,$email_number,2);

        /* output the email header information */
        $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
        $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
        $output.= '<span class="from">'.$overview[0]->from.'</span>';
        $output.= '<span class="date">on '.$overview[0]->date.'</span>';
        $output.= '</div>';

        /* output the email body */
        $output.= '<div class="body">'.$message.'</div>';
    }

    echo $output;
} 

/* close the connection */
imap_close($inbox);
?>
然后我在中手动创建了该文件

/etc/httpd/conf.d/fcgid.conf
并添加了下面的代码

<IfModule mod_fcgid.c>
    FcgidIdleTimeout 3600
    FcgidProcessLifeTime 3600
    FcgidIOTimeout 3600
    FcgidBusyTimeout 3600
</IfModule>

FcgidIdleTimeout 3600
FcgidProcessLifeTime 3600
FcgidIOTimeout 3600
FcgidBusyTimeout 3600
您的错误如下:

[Tue Jun 17 23:42:12 2014] [warn] [client 24.120.116.118] mod_fcgid: read data timeout in 40 seconds
[Tue Jun 17 23:42:12 2014] [error] [client 24.120.116.118] Premature end of script headers: this.php
[Tue Jun 17 23:42:12 2014] [error] [client 24.120.116.118] File does not exist: /home/cesarbi1/public_html/500.shtml
在我看来,错误在第一行:

mod_fcgid: read data timeout in 40 seconds
查看您通过IMAP连接的脚本,然后在读取电子邮件时直接输出到浏览器(我猜是这样的)?好吧,如果你有一个中等大小的邮箱,那40秒很快就会被消耗掉

因此,您可能需要在这里进入您的
FastCGI
config;假设您使用的是Linux安装程序:

/etc/httpd/conf.d/fcgid.conf
并将此行编辑为类似以下内容:

FcgidIOTimeout 120
相当于两分钟。对于一个实际的web服务器应用程序来说,这仍然是一条很高的路,但应该可以解决这个问题。只需更改该行,重新启动Apache并再次测试它。如果您使用的是Ubuntu,您将按如下方式重新启动Apache:

sudo service apache2 restart

对我来说,听起来像是防火墙。@Eric刚刚检查过,这可能是一个否定的重复,虽然这是一个类似的问题,但解决方案非常不同,正如我在更新中解释的那样。我有一个VPS Bluehost帐户,支持人员似乎不知道如何为我解决这个问题。该目录中没有
/etc/httpd/conf.d/fcgid.conf
文件,即使我创建了它,仍然没有任何内容。我的服务器是一个
CENTOS 6.5 x86_64 kvm–服务器
@CesarBielich嗯,在这个
/etc/httpd/
中的某个地方,设置了
FcgidIOTimeout
。我建议下载整个
http
目录。这只是配置文件,所以它们不是很大。将它们全部下载到您的桌面计算机。并在其中搜索“快速CGI”配置。这个网站解释了我提到的CentOS的东西。这里有一个链接,指向
grep-R“FcgidIOTimeout”/etc/httpd
的输出。请告诉我@CesarBielich在哪里您在整个文件系统上执行了
grep-R“FcgidIOTimeout”/
?你想让我做什么?对不起,我没有得到报酬。祝你好运!我说我做了
grep-R“FcgidIOTimeout”/etc/httpd
sudo service apache2 restart