0

I am currently setting up a new Mac Mini Lion server. I am now installing mongodb and apc extension. I want to include the ini settings for the extensions on the /etc/php.d directory (similar with my server settings on centOS)

I tried to do

php -i | grep php.d

and it gives me

Scan this dir for additional .ini files => /etc/php.d/
Additional .ini files parsed => /etc/php.d/apc.ini,
/etc/php.d/mongo.ini
PHP_INI_SCAN_DIR => /etc/php.d/
_SERVER["PHP_INI_SCAN_DIR"] => /etc/php.d/

But when I tried on phpinfo() on a php script, I got:

Configuration File (php.ini) Path   /etc
Loaded Configuration File   /private/etc/php.ini
Scan this dir for additional .ini files     (none)
Additional .ini files parsed    (none) 

The php environment on CLI and php script is the same which php

/usr/bin/php

and on php script page

PATH /usr/bin:/bin:/usr/sbin:/sbin

Is there anything I should set on the apache side?

I am thinking to stick with the Built-in apache and php from the mac installation because I like the Server App from Mac.

bbnn
  • 209
  • 1
  • 3
  • 10

1 Answers1

3

Looks like PHP CLI is using /etc/php.ini file, verify with:

php -i | grep 'Configuration File'

While Apache is loading the /private/etc/php.ini file:

Configuration File (php.ini) Path   /etc
Loaded Configuration File   /private/etc/php.ini

Point to the right php.ini file which you want by PHPINIDir directive.


EDIT

Don't know why phpinfo() ignore the additional .ini files but it can be force to scan in 2 ways:

  1. insert the below line before starting Apache in init script

    export PHP_INI_SCAN_DIR=/etc/php.d
    
  2. add the following to the Apache configuration file:

    php_value include_path "/etc/php.d"
    
quanta
  • 50,327
  • 19
  • 152
  • 213
  • /etc/ directory is actually just a symlink of /private/etc/ – bbnn Aug 21 '11 at 07:21
  • lrwxr-xr-x@ 1 root wheel 11 7 25 17:43 etc -> private/etc – bbnn Aug 21 '11 at 07:21
  • I tried php -i | grep 'Configuration File' and it gave me Configuration File (php.ini) Path => /etc Loaded Configuration File => /private/etc/php.ini – bbnn Aug 21 '11 at 07:28
  • What's the output of `ls -l /etc/php.d/`? Run `strace -ofile -f -o /tmp/apache.log /script/to/start/apache`, paste the log to pastebin and insert link here. – quanta Aug 21 '11 at 08:29
  • for ls -l /etc/php.d/ -rw-rwxrwx 1 root wheel 213 Aug 21 06:13 apc.ini -rw-rwxrwx 1 root wheel 19 Aug 21 06:11 mongo.ini – bbnn Aug 21 '11 at 10:00
  • for strace, I dont have strace, what is that for? – bbnn Aug 21 '11 at 10:00
  • Give me the result after testing the above suggested ways. – quanta Aug 21 '11 at 10:59
  • I think the step no 1 make sense, bcos in the PHP variables from CLI, it shows _SERVER["PHP_INI_SCAN_DIR"] => /etc/php.d/ but nothing on the Apache side. I define export PHP_INI_SCAN_DIR variable in the ~/.bash_profile is there any where else I can define it so that Apache can read it? thanks – bbnn Aug 21 '11 at 15:26
  • I'm not a OSX guy, but I think you can define in `/usr/sbin/apachectl`. How about the second way? – quanta Aug 21 '11 at 15:37
  • @hachiari let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/1142/discussion-between-quanta-and-hachiari) – quanta Aug 21 '11 at 15:37