dqd3690 2016-02-05 16:09
浏览 57
已采纳

php cli custom ini没有加载

A script is called from command line using :

/fullpath/php -q -c /fullpath/php.ini /fullpath/script.php

I want it to use the normal php.ini and not the one for cli, but the -c flag is not working.

What could cause this ?

  • 写回答

1条回答 默认 最新

  • doulang9521 2016-02-05 16:23
    关注

    You can check which configuration files are actually loaded with the --ini switch.

    Here's what my normal configuration looks like:

    krakjoe@fiji:/usr/src/php-src$ php --ini
    

    Yields:

    Configuration File (php.ini) Path: /etc
    Loaded Configuration File:         /etc/php-cli.ini
    Scan for additional .ini files in: /etc/php.d
    Additional .ini files parsed:      /etc/php.d/apcu.ini,
    /etc/php.d/auto.ini,
    /etc/php.d/autostrict.ini,
    /etc/php.d/ds.ini,
    /etc/php.d/inspector.ini,
    /etc/php.d/memcached.ini,
    /etc/php.d/mongodb.ini,
    /etc/php.d/mysql.ini,
    /etc/php.d/opcache.ini,
    /etc/php.d/pdo.ini,
    /etc/php.d/uopz.ini,
    /etc/php.d/xdebug.ini,
    /etc/php.d/yaml.ini
    

    Note that, it loads php-cli.ini, because it exists and we are in cli.

    If we do this:

    krakjoe@fiji:/usr/src/php-src$ php -c php.ini-development --ini
    

    We get:

    Configuration File (php.ini) Path: /etc
    Loaded Configuration File:         /usr/src/php-src/php.ini-development
    Scan for additional .ini files in: /etc/php.d
    Additional .ini files parsed:      /etc/php.d/apcu.ini,
    /etc/php.d/auto.ini,
    /etc/php.d/autostrict.ini,
    /etc/php.d/ds.ini,
    /etc/php.d/inspector.ini,
    /etc/php.d/memcached.ini,
    /etc/php.d/mongodb.ini,
    /etc/php.d/mysql.ini,
    /etc/php.d/opcache.ini,
    /etc/php.d/pdo.ini,
    /etc/php.d/uopz.ini,
    /etc/php.d/xdebug.ini,
    /etc/php.d/yaml.ini
    

    This time php-cli.ini was not loaded, the specified one was, but so were all the files in scan dir too.

    Finally, if we do this:

    krakjoe@fiji:/usr/src/php-src$ php -c php.ini-development -n --ini
    

    We get:

    Configuration File (php.ini) Path: /etc
    Loaded Configuration File:         /usr/src/php-src/php.ini-development
    Scan for additional .ini files in: (none)
    Additional .ini files parsed:      (none)
    

    So, adding the additional switch -n, stops PHP from using the scan directory configuration.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效