SugarCRM appliance has two php.ini Which is the right one to change?

Bunk3m's picture

I've been playing with the SugarCRM appliance for a few weeks now.  I've noticed a number of errors which I tried to fix using the php.ini located at /etc/php/apache2/php.ini.  No changes seemed to work.

Yesterday I chanced across another php.ini located at /etc/php/cli/php.ini.  Changes made here seemed to fix a number of the errors from the logs.

So would someone answer a few newbie questions?

1) Why are there two php.ini files? 

2) Do I need both?

3) How does php decide which to use?

4) For future reference, how do I figured out which php.ini is being used by sugarcrm or other app?

5) Can I force sugarcrm or php to use the one at /etc/php/apache2/php.ini?  Seems this is the one I read about mostly being used by sugarcrm on debian.



Jeremy Davis's picture

So don't take this as gospel... but:

1) AFAIK /etc/php/apache2/php.ini applies to PHP via Apache (i.e. as it applies to the Web side of SugarCRM) and /etc/php/cli/php.ini applies to PHP run from the commandline (e.g. when run manually from the commandline or via a cron job). IIRC often one is a symlink to the other (although it sounds like that is not the case in this instance).

2) Assuming that you want to run PHP from the commandline then yes (see above for why). I am not familiar with SugarCRM specifically but from my experience many PHP webapps use cron jobs to do background processing so I imagine that it would be neccessary.

3) see 1 above

4) see 1 above (Often web apps use cron jobs to run tasks in the back ground).

5) AFAIK you could rename /etc/php/cli/php.ini (as a precautionary step) and in it's place create a symlink to /etc/php/apache2/php.ini

mv /etc/php/cli/php.ini /etc/php/cli/php.ini.backup
ln -s /etc/php/apache2/php.ini  /etc/php/cli/php.ini

Also note that because of the nature of the different way PHP runs within the web server vs from the commandline, changes to /etc/php/apache2/php.ini are not applied until Apache is restarted, whereas any new PHP instances started after changes to /etc/php/cli/php.ini should apply immediately.

service apache2 restart

Bunk3m's picture

Thanks Jeremy.  That makes sense.  But, I'm not sure if that how this appliance is working.

Weird thing is that when I do

php -i

I get

Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
Scan this dir for additional .ini files => /etc/php5/cli/conf.d
Additional .ini files parsed => /etc/php5/cli/conf.d/curl.ini,

So since this came from the command line, it probably should show ../cli/php.ini etc.

But when I've made the changes to /etc/php5/apache2/php.ini and do the service apache2 restart, the changes aren't taken and SugarCRM continues to show errors.  I didn't notice this until a few days ago when SugarCRM kept on giving me an error that it didn't know the date.timezone. I put the date-timezone="America/Toronto"  in /etc/php5/apache2/php.ini a few weeks ago.  So I couldn't figure out why it wasn't working.  Then I found this php -i command and found there were two of these ini files.

Now that I put the date.timezone into /etc/php5/cli/php.ini there is no SugarCRM appliance error.


Jeremy Davis's picture

But if it's now working, don't fight it! :)

Although if you are curious about why this may be the case, perhaps it is worth enquiring on the SugarCRM forums (or mailing list, or whatever - I'm not sure what sort of community support mechanism they provide).

It could be useful info for the devs (depending on what SugarCRM community says - perhaps it's even a TKL bug of sorts).

Post new comment