Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've just installed Zend Server Community Edition on a Windows Server 2003 box, however there's a bit of a problem with the display of a lot of our PHP pages. The code has previously running under the same version of PHP (5.3) on IIS without any issues.

By the looks of things, Apache (installed as part of Zend Server) is erroring out during the rendering of the page when it comes across something it doesn't like in the PHP. Going through the code, I've been able to get past some of the problems by removing the error suppression operator (@) from function calls and by changing the format of some includes. However, I can't do this for the whole site!

Weirdly, the error code is reported as "200 OK". The code snippet below shows how the Apache error HTML interrupts the regular HTML of the page.

<p>Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues.</<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>200 OK</title>
</head><body>
<h1>OK</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 example@example.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log

The Apache error log doesn't offer any explanation for this, and I've exhausted my Googling skills, so any help would be greatly appreciated. Thanks.

share|improve this question

2 Answers 2

You'll want to look through your code.

My immediate line of thinking is that you're include()ing (or similar function) a page or script via HTTP (you have allow_url_fopen enabled), and the server the included page/script is running on is having issues.

If you edit php.ini (and restart Apache) to change allow_url_fopen to false, you'll have better security in your hosting environment as well as most likely get a better error, telling you where you're trying to include a broken URL.

share|improve this answer
    
Thanks for your reply. However, allow_url_fopen is already off. Admittedly, a couple of the "fixes" have been to do with changing includes, but none are via HTTP and this has not been the only cause of the error appearing. –  Shep Sep 24 '09 at 8:26

The @ error suppression operator is expensive - a better option is to use error_reporting( 0 ) to disable errors, or use your own function.

In this case, seeing as you have no info at all, you could try using this error handler in place of your default handler to see if you can tie this error to a PHP function crashing apache.

function Andy_errorHandler( $errno, $errstr, $errfile, $errline ) {
	$stack_trace = '';
	switch ( $errno ) {
        case E_NOTICE:
        case E_USER_NOTICE:
		case E_STRICT:
			return;
            break;
		default:
			try {   
				throw new Exception( $errstr, $errno );   
			} catch( Exception $e ) {
				//build stack trace
				$stack_trace .= "File: <b>$errfile</b> Line: <b>$errline\n" . $e->getMessage() . "</b>\n" . "Error No: ".$e->getCode(). "\n";
				$stack_trace .= $e->getTraceAsString();
			}		
		break;
	}

	if( ! isset( $GLOBALS['error_handler_output'] ) ) {
		$GLOBALS['error_handler_output'] = nl2br( $stack_trace ) . '<p/>'; 
	} else {
		$GLOBALS['error_handler_output'] .= nl2br( $stack_trace ) . '<p/>'; 
	}

	return true;
}
$old_error_handler = set_error_handler( "Andy_errorHandler" );
share|improve this answer
    
Couldn't agree more on the @ advice. Unfortunately the code is quite old and busted and could do with a rewrite. I'll give the error handler function a go later today and see if it sheds any light. Thanks! –  Shep Sep 24 '09 at 8:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.