最近更换服务器的时候,Centos的系统也换成的7的版本,发现在执行curl的时候,响应的速度也变慢了,接下来吾爱编程就为大家介绍一下Centos下curl执行慢的解决方法,有需要的小伙伴可以参一下:
1、测试响应速度:curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" 'https://www.itbiancheng.com'
返回结果如下:0.013::0.019::0.274::0.275::119281.000
参数解释:
2、解决方法一:升级libcurlmkdir /tmp/libcurl && cd /tmp/libcurl && wget http://dl.fedoraproject.org/pub/archive/fedora/linux/updates/19/x86_64/curl-7.29.0-27.fc19.x86_64.rpm && wget http://dl.fedoraproject.org/pub/archive/fedora/linux/updates/19/x86_64/libcurl-7.29.0-27.fc19.x86_64.rpm && wget http://dl.fedoraproject.org/pub/archive/fedora/linux/updates/19/x86_64/libcurl-devel-7.29.0-27.fc19.x86_64.rpm && yum -y install *.fc19.x86_64.rpm
然后重启php-fpm,因为我的是php的项目service php-fpm restart
3、解决方法二:在/etc/resolv.conf的可选参数后里加上:single-request-reopen
第一行内容既改为:
options timeout:1 attempts:1 rotate single-request-reopen
以上就是吾爱编程为大家介绍的关于Centos下curl执行慢的解决方法,了解更多相关文章请关注吾爱编程网!