PHP include() through HTTP makes Apache time out
Posted
by
Adam Interact
on Server Fault
See other posts from Server Fault
or by Adam Interact
Published on 2013-04-08T19:16:18Z
Indexed on
2013/06/25
10:23 UTC
Read the original article
Hit count: 345
I have a problem with ExpressionEngine2 after moving from an old server to WHM/cPanel running on CentOS6.4. Simple test code to reproduce that issue:
<?php
$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https';
$host = $_SERVER['HTTP_HOST'];
include($protocol . '://' . $host . '/header.html');
?>
<p> Main text...</p>
<?php
include($protocol . '://' . $host . '/footer.html');
?>
Where header.html looks like
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
and footer.html looks like:
</body>
</html>
Creates Apache time out:
Warning: include(http://www.domain.com/header.html) [function.include]: failed to open stream: Connection timed out in /home/domain/public_html/test/index.php on line 5
Warning: include() [function.include]: Failed opening 'http://www.domain.com/header.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/domain/public_html/test/index.php on line 5
Main text...
Warning: include(http://www.domain.com/footer.html) [function.include]: failed to open stream: Connection timed out in /home/domain/public_html/test/index.php on line 12
Warning: include() [function.include]: Failed opening 'http://www.domain.com/footer.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/domain/public_html/test/index.php on line 12
Any clue what can be wrong with Apache or PHP configuration?
Thanks
© Server Fault or respective owner