【问题标题】:PHP CLI has a few seconds delayPHP CLI 有几秒钟的延迟
【发布时间】:2015-04-08 17:20:03
【问题描述】:

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

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

【问题讨论】:

    标签: php centos command-line-interface delay


    【解决方案1】:

    这个问题与 PHP 正在做的 DNS 调用有关。请参阅herehere

    解决方法是添加主机名

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

    到 /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
    

    【讨论】:

      猜你喜欢
      • 2019-10-25
      • 2022-01-18
      • 2018-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多