title: php - imap_open producing 500 Internal Server Error & no fcgid.conf file in /etc/httpd/conf.d/ folder
body: <p>I am using the following script to access my gmail from php called <code>this.php</code></p>
  
  <p>I have regered to <a href="https://stackoverflow.com/questions/12037862/imap-is-not-working-in-php">IMAP is not working in PHP</a> as well as <a href="https://stackoverflow.com/questions/15804428/imap-error-on-mynamemydomain-com-but-working-on-mynamegmail-com">Imap error on myname@mydomain.com but working on myname@gmail.com</a></p>
  
  <p>I have confirmed that opensll and imap extensions are loaded into Apache.</p>
  
  <p>I have confirmed file permission on the file</p>
  
  <p>In apache logs the only error I get is</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>No matter what I get a 500. If I comment out the line with <code>imap_open</code> then the page does not 500.</p>
  
  <p>Is there somewhere else I can look for errors? or can someone tell me whats wrong with my script?</p>
  
  <pre><code>&lt;?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.= '&lt;div class="toggler '.($overview[0]-&gt;seen ? 'read' : 'unread').'"&gt;';
          $output.= '&lt;span class="subject"&gt;'.$overview[0]-&gt;subject.'&lt;/span&gt; ';
          $output.= '&lt;span class="from"&gt;'.$overview[0]-&gt;from.'&lt;/span&gt;';
          $output.= '&lt;span class="date"&gt;on '.$overview[0]-&gt;date.'&lt;/span&gt;';
          $output.= '&lt;/div&gt;';
  
          /* output the email body */
          $output.= '&lt;div class="body"&gt;'.$message.'&lt;/div&gt;';
      }
  
      echo $output;
  } 
  
  /* close the connection */
  imap_close($inbox);
  ?&gt;
  </code></pre>
  
  <p><strong>SOLVED UPDATE</strong></p>
  
  <p>While this question is of the same nature of the other question, the other one does not provide a solution for those of us without <code>fcgid.conf</code> located in the <code>/etc/httpd/conf.d/</code> folder. I am also editing my title to be more specific to the error.</p>
  
  <p>I fixed my issue by adding at the end of my file httpd.conf</p>
  
  <pre><code>Include "/etc/httpd/conf.d/cfgid.conf"
  </code></pre>
  
  <p>and then I manually created the file in</p>
  
  <pre><code>/etc/httpd/conf.d/fcgid.conf
  </code></pre>
  
  <p>and added the following code which worked.</p>
  
  <pre><code>&lt;IfModule mod_fcgid.c&gt;
      FcgidIdleTimeout 3600
      FcgidProcessLifeTime 3600
      FcgidIOTimeout 3600
      FcgidBusyTimeout 3600
  &lt;/IfModule&gt;
  </code></pre>