Unable to make external calls from PHP script using cURL

  apache, php

I am using ubuntu server, testing to fetch an external url with wget and cURL in terminal via putty.

wget www.google.com

works fine and i got response.

curl -v www.google.com

works find and i got response

Now in my php script i have

$url = 'www.google.com';
$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, $url);
curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, 0);
$jsonData = json_decode(curl_exec($curlSession));

var_dump("curl without proxy ", $jsonData);
echo "<br>";
echo "<br>";

I am getting NULL as response

enter image description here

When i test it with a fresh server or localhost or another server, the code is working fine.

Is there any settings that need to be checked. In php.ini settings

allow_url_fopen is ON

Source: Ask PHP