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

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.

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

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀