Apache time out on PHP include() or file_get_contents() through HTTP

InteractM

Well-Known Member
Apr 2, 2013
135
1
18
cPanel Access Level
Root Administrator
I have a problem with ExpressionEngine2 after moving from an old server to WHM/cPanel. Simple test code to reproduce that issue (childrensmedgroup2.com/test/):

PHP:
<?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

Code:
<!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:

Code:
</body>
</html>
Creates Apache time out:

Code:
Quote:

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
Same problem when I use file_get_contents() instead include().

Any clue what can be wrong with Apache or PHP configuration?

Thanks
 

InteractM

Well-Known Member
Apr 2, 2013
135
1
18
cPanel Access Level
Root Administrator
Looking for help on Apache/PHP issue

Issue is described here: forums.cpanel.net/f442/apache-time-out-php-include-file_get_contents-through-http-336542.html

Looking for help on that.