1
0
Setup:
- cURL 7.32.0
- Apache 2.2.25
- PHP 5.5.4
Whenever I attempt to:
$ch = curl_init('www.google.com');
curl_exec($ch);
var_dump(curl_error($ch));
within PHP, I get:
Could not resolve host: www.google.com
If I change to curl_init('80.233.168.207')
(resolved google.com), the script executes.
Though, running curl www.google.com
in CLI, I get a 302 Moved
HTML page, due to redirect to localized site (*.lv), but still, that means that cURL executed successfully.
I have seen multiple similar questions (not on SE though), most of them saying that Apache is started either before or concurrently with Network Manager, hence not receiving DNS information. Most of the questions have answers explaining, that the issue can be temporarily resolved/debugged by explicitly stopping, then starting the Apache daemon (instead of restart/graceful-restart).
fsockopen
, file_get_contents
works flawlessly, though.
My Apache virtual host:
<VirtualHost *.777>
ServerAdmin stone@altas.lv
ServerName localhost
DocumentRoot "/srv/stone/public"
ErrorLog "/srv/stone/app/storage/logs/apache-errors.log"
CustomLog "/srv/stone/app/storage/logs/apache-custom.log" common
<Directory /srv/stone/public>
php_admin_value open_basedir /
# Pretty URL rewrites, better not to rely on .htaccess
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
# Prevent further overrides
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And global config just has a specific entry for Listen 777
.
This and this, both lead to DNS problem, so, I think I may have problems with it too, plus, it clearly looks like it.
I've given a shot by changing virtual host entries to 0.0.0.0:777
and other configurations to no avail.
How do I fix the issue?
If you try to put
80.233.168.207 www.google.com
in your/etc/hosts
you should be able to confirm that this is a DNS issue. It's a bit strange that your CLI command manage to perform the lookup though. FYI, the code works on myApache
installation. – Qben – 2013-09-25T11:20:33.957Adding it to hosts did make the script work. – joltmode – 2013-09-25T11:33:44.370