Ubuntu
php5.6-fpm curl 停止工作(無法解析主機)
突然間,我們的 Ubuntu php5.6-fpm 伺服器停止處理 curl 請求。
這是我發現的:
從控制台執行時工作
php test.php
。通過潮濕的工作
console wget -qO- https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4 | cat
使用 curl 從
console ums-admin@svr1:/var/www/propertymonitor.ae/htdocs/v2$ curl https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4
但是通過https://example.com/test.php上的 php-fpm 呼叫腳本它不起作用並抱怨 DNS 查找失敗?!
重新啟動 php5.6-fpm 並再次開始工作?!
下面的程式碼:
<?php // create curl resource $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, "https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4"); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $data = curl_exec($ch); if ($data === false) { echo 'Curl error: ' . curl_error($ch); } else { echo 'Response: ' . $data; } // close curl resource to free up system resources curl_close($ch); ?>
系統的其餘部分檢查:
cat /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 8.8.8.8 nameserver 8.8.4.4 search example.com
並且沒有丟包:
64 bytes from 8.8.8.8: icmp_seq=3150 ttl=46 time=129 ms 64 bytes from 8.8.8.8: icmp_seq=3151 ttl=46 time=124 ms 64 bytes from 8.8.8.8: icmp_seq=3152 ttl=46 time=124 ms 64 bytes from 8.8.8.8: icmp_seq=3153 ttl=46 time=124 ms ^C --- 8.8.8.8 ping statistics --- 3153 packets transmitted, 3153 received, 0% packet loss, time 3154312ms rtt min/avg/max/mdev = 114.975/124.705/139.692/2.004 ms
見這裡:https ://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1674733
更新導致了這個問題。
似乎該錯誤已修復並已發布。