My server previously did not have the command-line php package installed (php5-cli; debian), only apache2 mod_php; php5-cli was only installed to support Drush.
When php5-cli was installed, it created it's own config file in /etc/php5/cli and that's what it uses when php is run from the shell.

However, apache2 uses it's own config file at /etc/php5/apache2/php.ini

The Drush 'status' command incorrectly lists /etc/php/cli/php.ini as the config file for the site queried.

Fortunately, apache2 does *not* use php5-cli's config file, as it ships (for debian, at least) with magic_quotes_gpc=On

Besides causing confusion, could this cause an actual problem if for instance the ../conf.d/*.ini files differed significantly between the apache2 and php5-cli config files? (specifically mysql/mysqli.ini)

sidebar: could be related to this?


PHP Version 5.2.6-1+lenny3

System Linux svr-web 2.6.24-1-686 #1 SMP Thu May 8 02:16:39 UTC 2008 i686
Build Date Apr 26 2009 21:57:45
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php5/apache2
Loaded Configuration File /etc/php5/apache2/php.ini
Scan this dir for additional .ini files /etc/php5/apache2/conf.d
additional .ini files parsed /etc/php5/apache2/conf.d/gd.ini, /etc/php5/apache2/conf.d/mcrypt.ini, /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini

$ php --ini

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/gd.ini,



dman’s picture

I encountered this also, and also hit a little confusion at the time.
But this is a quirk of your OS and PHP distribution and configuration.
By the time drush is invoked, the OS has already decided which php version and settings it wants to use! And all drush can do is report that.
Actually, the fact that it does report it made the discrepancy easy to spot!

So I guess the thing to do is adjust your PATH to use the same php binary as your webserver, or adjust the line in the drush shell script
/usr/bin/env php to something else.

Owen Barton’s picture

Status:Active» Closed (works as designed)

The point of listing the php.ini file in use here is to show the file that the php running drush is using (which it appears to be doing quite accurately), because a common cause of issues running drush is because people don't realize that there can be a separate php.ini file for php-cli, and wonder why they get memory errors even through they already increased the memory_limit for the web server php's php.ini.

It is impossible to, from the command line, determine which php.ini used when the site is accessed via a web server (and in fact there could be more than one, since there is nothing stopping you running multiple web servers or even multiple php installs simultaneously accessing the same site files/database), and this wouldn't give any useful information in diagnosing issues with drush (in fact, it would likely reinforce peoples incorrect assumptions).

If you can think of a way to make the intent here clearer in the status report or the documentation then patches are welcome, but this functionality is by design :)

Mike_Waters’s picture

If you can think of a way to make the intent here clearer in the status report

"PHP Configuration" is the only item in the status output that is not relevant to the site queried with -l; I was quite confused when presented with it initially.

Perhaps "Drush PHP Configuration", or a drush-status command?

Thanks for the excellent tool btw...

tom friedhof’s picture

Component:Installation» PM (dl, en, up ...)

Not sure how the OS determines which php.ini file to use, but ever since I installed Acquia Dev Desktop now drush does not use the php.ini file it used to. Instead it uses the php.ini file in Acquia Drupal. If I delete the acquia php.ini file, drush doesn't load a php.ini file.

Is there a way I can set drush to use the same php.ini file that is shown in php --ini? I'm having to symlink to the right php from the acquia location to get things working for now. Hoping someone has some pointers on fixing this so I don't have to this little symlink hack.

$ php --ini
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.3.6/conf
Loaded Configuration File:         /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

$ drush st
PHP configuration     :  /Applications/acquia-drupal/php/bin/php.ini                  
Drush version         :  4.6-dev                                                      
Drush configuration   :                                                               
Drush alias files     :
dman’s picture

That is correct.
Drush does some silly business, hard-coded in the first script it uses - do assume that if acquia is on your system, that's the one to use. No matter what the reality of your system environment really is.
I imagine this makes things smoother for folk who only interact with the Acquia GUI ... but was not what I wanted

  # Special case for *AMP installers, since they normally don't set themselves as the default cli php out of the box.
  for amp_php in /Applications/MAMP/bin/php5/bin/php /Applications/MAMP/bin/php5.2/bin/php /Applications/MAMP/bin/php5.3/bin/php /opt/la
mpp/bin/php /Applications/xampp/xamppfiles/bin/php /Applications/acquia-drupal/php/bin/php; do
    if [ -x $amp_php ]; then

IIRC, I got around it (after deleting the offending passage a few times) by setting my own environment variable

- by defining the right php binary to use, you also usually hint the system to use the right php.ini for your installation also

There are a number of other things you can tweak as drush environment overrides in that script too.