where can I find the php.ini for php-cli

2019-01-04 11:28发布

It appears that the php command line is using a different php.ini from the main php interpreter. I am using Ubuntu 10.4. My problem is that in the main php.ini I have included an extra path for an external library, but in the cli version this is not present, and so I have a path inclusion error.

thanks

标签: php php-ini
7条回答
一纸荒年 Trace。
2楼-- · 2019-01-04 11:47

Interesting in windows is that in both tests (on apache with phpinfo() and in cli with php --ini), the configuration file path is c:\windows. More info here

查看更多
来,给爷笑一个
3楼-- · 2019-01-04 11:59

Better yet: $ php --ini

This will also show all extra *.ini files loaded (usually hanging around in some conf.d dir in debian):

Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File: /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed: /etc/php5/cli/conf.d/apc.ini,
/etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/gd.ini,
/etc/php5/cli/conf.d/geoip.ini,
/etc/php5/cli/conf.d/imagick.ini,
/etc/php5/cli/conf.d/imap.ini,
/etc/php5/cli/conf.d/ldap.ini,
/etc/php5/cli/conf.d/memcache.ini,
/etc/php5/cli/conf.d/memcached.ini,
/etc/php5/cli/conf.d/ming.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini,
/etc/php5/cli/conf.d/pdo_sqlite.ini,
/etc/php5/cli/conf.d/snmp.ini,
/etc/php5/cli/conf.d/sqlite.ini,
/etc/php5/cli/conf.d/sqlite3.ini,
/etc/php5/cli/conf.d/suhosin.ini,
/etc/php5/cli/conf.d/tidy.ini,
/etc/php5/cli/conf.d/xdebug.ini,
/etc/php5/cli/conf.d/xsl.ini

Note that this was about php-cli, php-cgi does not have this afaik.

查看更多
小情绪 Triste *
4楼-- · 2019-01-04 12:01

You can find php.ini using the below command. in LINUX

find / -name php.ini

or

locate php.ini
查看更多
仙女界的扛把子
5楼-- · 2019-01-04 12:03

Just ask PHP:

$ php -i |grep php\.ini

查看更多
该账号已被封号
6楼-- · 2019-01-04 12:04

I had the same problem. Simply check owner and permissions from every files in /etc/php5/conf.d/. It has to be owned by root and readeable by anymone.

查看更多
【Aperson】
7楼-- · 2019-01-04 12:06

At my last job, I got in the habit of specifying my ini file on every execution...

C:\php\cli\php.exe -c C:\php\php.ini myscript.php
查看更多
登录 后发表回答