PHP CLI自定义INI不加载 [英] php cli custom ini not loading
问题描述
使用以下命令从命令行调用脚本:
A script is called from command line using :
/fullpath/php -q -c /fullpath/php.ini /fullpath/script.php
我希望它使用普通的php.ini,而不是用于cli的php.ini,但是-c标志不起作用.
I want it to use the normal php.ini and not the one for cli, but the -c flag is not working.
是什么原因造成的?
推荐答案
您可以使用-ini
开关检查实际加载的配置文件.
You can check which configuration files are actually loaded with the --ini
switch.
这是我的常规配置:
krakjoe@fiji:/usr/src/php-src$ php --ini
收益:
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
请注意,它会加载 php-cli.ini
,因为它存在并且我们在 cli
中.
Note that, it loads php-cli.ini
, because it exists and we are in cli
.
如果我们这样做:
krakjoe@fiji:/usr/src/php-src$ php -c php.ini-development --ini
我们得到:
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
这次未加载 php-cli.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
我们得到:
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)
因此,添加额外的开关 -n
会阻止PHP使用扫描目录配置.
So, adding the additional switch -n
, stops PHP from using the scan directory configuration.
这篇关于PHP CLI自定义INI不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!