3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
最近發生 PHP 呼叫其他 WebService 速度過慢的問題,在 Linux OS 使用 TCP Socket 進行 HTTP 連線速度正常,但是使用 PHP 呼叫 fsockopen() 或 file_get_contents() 就是特別慢。仔細測試後發現如果是使用 IP Address 進行連線速度就正常,使用 Domain 就特別慢,看來問題就是出在 DNS 解析! 後來發現 Linux 的 IPv6 是不工作的,一般來說裝好 Linux 我都會關閉 IPv6 的相關功能與設定,接著關閉 IPv6 之後 PHP 的連線速度也就正常了。以下是關閉 Linux IPv6 的方法: Disable IPv6 Networking Support - 關閉 IPv6 網路支援 編輯 /etc/sysconfig/network 並加入以下設定 1 NETWORKING_IPV6=no Disable IPv6 Protocol Stack for Kernel - 關閉 IPv6 相關 module 編輯 /etc/modprobe.conf 並加入以下設定 1 2 alias net-pf-10 off alias ipv6 off Disable IPv6 Firewall - 關閉 IPv6 iptables 防火牆支援 1 2 3 4 5 6 7 [root@server ~]$ /etc/init.d/ip6tables stop Flushing firewall rules: [ OK ] Setting chains to policy ACCEPT: filter [ OK ] Unloading ip6tables modules: [ OK ] Turn ipv6 firewall off during future usage:   [root@server ~]$ /sbin/chkconfig --level 35 ip6tables off Issue with localhost - 註解所有 IPv6 Hosts 編輯 /etc/hosts 註解所有 IPv6 解析設定 1 #::1    localhost.localdomain   localhost 參考資料 Disable IPv6 Features 分享到 Twitter(在新視窗中開啟) 按一下以分享至 Facebook(在新視窗中開啟) 分享到 LinkedIn(在新視窗中開啟) 點這裡寄給朋友(在新視窗中開啟) 按一下即可分享至 Skype(在新視窗中開啟) 分享到 Reddit(在新視窗中開啟) 分享到 Tumblr(在新視窗中開啟) 按一下以分享到 Telegram(在新視窗中開啟)

本文由toright提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦