Firstly, I'm using Windows (XP -- yes, I know), php-fpm (5.4.9) and nginx (1.5.10). My local development environment is functioning well.
I use the .dev
extension for local domain names to point to local website projects. For example: example.dev
or www.example.dev
.
I've setup my hosts file (C:\Windows\System32\drivers\etc\hosts
) to contain these additional records:
127.0.0.1 example.dev www.example.dev
When I ping them the domain name www.example.dev
it resolves to 127.0.0.1
as you would expect.
I can visit the page: http://www.example.dev
in my browser and it displays some 'Hello World' text as you would expect to see.
Now if I run the following script in a browser, it does not work:
<?php var_dump( file_get_contents( 'http://www.example.dev' ) ); ?>
For me nginx just times-out, even though I can navigate to it in my browser without issue.
Now for cURL, the follow doesn't work either:
<?php
$url = 'http://www.example.dev';
$ch = curl_init();
$options = array(
'CURLOPT_URL' => $url,
'CURLOPT_HEADER' => TRUE,
'CURLOPT_FAILONERROR' => FALSE,
'CURLOPT_FOLLOWLOCATION' => TRUE,
'CURLOPT_AUTOREFERER' => TRUE,
'CURLOPT_RETURNTRANSFER' => TRUE,
'CURLOPT_FRESH_CONNECT' => TRUE,
);
foreach ( $options as $k => $v )
{
curl_setopt( $ch, constant( $k ), $v );
};
$response = curl_exec( $ch );
$header_size = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
$status_code = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
$info = curl_getinfo( $ch );
curl_close( $ch );
var_dump( $response ); exit;
?>
However if I replace example.dev with localhost, these code samples do appear to work.