0

I'm experiencing a 500, Internal Server error on my website. The error logs show the following error: "Premature end of script headers: cgi_wrapper", in my Joomla application.

It only occurs when one particular file is loaded. The rest of the application/website works as it should. There are no other related issues that show up in the error logs - no indication of a timeout or a permissions error.

The file that is causing the error is a template/layout file. Furthermore, I have identified a snippet of code that will cause the error, when this is commented out, the site loads just fine. Here it is:

    if( $question->type == '1' || $question->type == '2' || $question->type == '3' )
    {
        //shuffle items
        $shuffled_items = $this->shuffle_assoc($items);
        $output = '';
        $output .= '<table class="answer-table">';
        $output .= '<tr>';
        $output .= '<td>';
        $output .= '<ul class="answers">';

        foreach($shuffled_items as $item)
        {
            $output .= '<li num=' . $item->num . '>';
            $output .= $item->item;
            $output .= '</li>';
        }

        $output .= '</ul>';
        $output .= '</td>';
        $output .= '</tr>';
        $output .= '</table>';

        $output .= '<table class="answer-table correct-answer" style="display: none">';
        $output .= '<tr>';
        $output .= '<td>';
        $output .= '<p class="question-instructions">Correct Answer:</p>';
        $output .= '<ul class="answers correct-answer">';

        foreach($items as $item)
        {
            $output .= '<li num=' . $item->num . '>';
            $output .= $item->item;
            $output .= '</li>';
        }

        $output .= '</ul>';
        $output .= '</td>';
        $output .= '</table>';

        echo $output;
    }

It uses a variable, $questions, that is set in the view.html.php file (for those who know Joomla). It is this variable that seems to be triggering the error. If I don't assign the $questions variable, then the template will load just fine.

Also, in the example above, it first tests the question type ($question->type). There are other sections of code that would be triggered, and still produce the error, if $question->type is not 1, 2, or 3. But I left out the other code for brevity, and because it only gets called when the relevant question type exists. When the code above alone gets run, it causes the error.

So, I'm lost here. What baffles me is that only this template file, and the $questions variable causes the error. Everything else works fine. It also runs fine on my local server.

Almost forgot, using Joomla 1.5.22, PHP 5.3.3, Apache 2.2.3, Cent OS 5.8. The server also runs Parallels Plesk Panel 10.

I hope someone can point me to a solution.

Thanks!

Ron
  • 231
  • 3
  • 10
  • The issue has since been resolved, even though I do not know what the problem was. The script was causing a segmentation fault on the server. Basically, we switched to a new server without Plesk and it worked just fine. I'm not sure if plesk was the issue, or if the VPS was corrupted somehow. I would have loved to know the cause of this, but unfortunately I have not time to figure it out. – Ron Jan 14 '13 at 04:01

1 Answers1

0

Check /var/log/httpd/suexec_log

and permissions on /var/www/cgi-bin/cgi_wrapper/cgi_wrapper

it should be

ls -la /var/www/cgi-bin/cgi_wrapper/cgi_wrapper

-rwxr-xr-x 1 root root 5288 Jul 14 2011 /var/www/cgi-bin/cgi_wrapper/cgi_wrapper

Oleg Neumyvakin
  • 9,706
  • 3
  • 58
  • 62
  • Thanks for the response. I've seen this answer all over the net. Unfortunately this didn't help me, the permissions are configured correctly. – Ron Jan 14 '13 at 03:58