PHP CLI有几秒钟的延迟 [英] PHP CLI has a few seconds delay

查看:482
本文介绍了PHP CLI有几秒钟的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在CLI模式下运行PHP(PHP 5.6.6在CentOS 6.5下运行作为VM使用VirtualBox)它有几秒的延迟,即使我只检查版本,并有php.ini文件被禁用:

When I run PHP in the CLI mode (PHP 5.6.6 under CentOS 6.5 running as VM using VirtualBox) it has a few seconds of delay even if I only check version and there is php.ini file disabled:

time php -n -v
PHP 5.6.6 (cli) (built: Apr  2 2015 14:18:24) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

real    0m5.066s
user    0m0.012s
sys     0m0.006s


推荐答案

问题是与DNS调用PHP是相关的。请参见此处此处

The problem is related to DNS call PHP is doing. See here and here.

解决方案是添加主机名

[root@dev-machine ~]# hostname
dev-machine.com

到/ etc / hosts:

to /etc/hosts:

127.0.0.1 dev-machine.com

结果:

time php -n -v
PHP 5.6.6 (cli) (built: Apr  2 2015 14:18:24) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

real    0m0.018s
user    0m0.012s
sys     0m0.004s

这篇关于PHP CLI有几秒钟的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆