How to find the php.ini file used by the command l

2019-01-02 16:30发布

I need to enable pdo_mysql in my EasyPhp environment, so I went to php.ini file and uncommented the following line:

extension=php_pdo_mysql.dll

Unfortunately I still have the same problem. I'm using the CLI so I suppose I need to locate the php.ini file used by the CLI. How can I find it?

标签: php easyphp
13条回答
十年一品温如言
2楼-- · 2019-01-02 16:56

Just run php --ini

查看更多
公子世无双
3楼-- · 2019-01-02 16:56

Do

find / -type f -name "php.ini" 

This will output all files named php.ini.

Find out which one you're using, usually apache2/php.ini

查看更多
不再属于我。
4楼-- · 2019-01-02 16:58

In your php.ini file set your extension directory, e.g:

extension_dir = "C:/php/ext/"

You will see in you PHP folder there is an ext folder with all the dll's and extensions.

查看更多
初与友歌
5楼-- · 2019-01-02 17:02
php --ini

will give you all the details details on the uses path and possible ini file(s)

查看更多
闭嘴吧你
6楼-- · 2019-01-02 17:02

You can use get_cfg_var('cfg_file_path') for that:

To check whether the system is using a configuration file, try retrieving the value of the cfg_file_path configuration setting. If this is available, a configuration file is being used.
Unlike phpinfo() it will tell if it didn't find/use a php.ini at all.

var_dump( get_cfg_var('cfg_file_path') );

And you can simply set the location of the php.ini. You're using the command line version, so using the -c parameter you can specifiy the location, e.g.

php -c /home/me/php.ini -f /home/me/test.php
查看更多
后来的你喜欢了谁
7楼-- · 2019-01-02 17:09

If you need to pass it to another app, you can do something like:

php --ini | grep Loaded | cut -d" " -f12

returns the path only. php -c $(php --ini | grep Loaded | cut -d" " -f12) will pass in the config file (useful for fpm)

查看更多
登录 后发表回答