3

I try to run a script from the command line, a script made by zend framework. I used also the Zend Server who has her own php.ini. When I try to start my script on the command line I am not able to connect with my mysql database. It's because from the command line it takes (it has to be) another php.ini file located somewhere on my Mac OS X Lion system because the path to the mysql.sock isnt the path who is configurated in the zend server php.ini.

I would like to let the command line use my php.ini of zend Server.

I hope someone knows how to do this.

Kind regards, Nicky

user968898
  • 161
  • 2
  • 5

1 Answers1

3

You can launch php from the command line with an option to specific the path where the php.ini file you want it to use is located:

php -c /path/to/zend/phpini/folder myfile.php

To find out the the folder where the command line php.ini is located, you can use:

php -i | grep php.ini
Paul
  • 59,223
  • 18
  • 147
  • 168
  • Thank you that works! But I get a lot of Warnings, like "Failed loading /usr/local/zend/lib/ZendExtensionManager.so: dlopen(/usr/local/zend/lib/ZendExtensionManager.so, 9): no suitable image found. Did find: /usr/local/zend/lib/ZendExtensionManager.so: mach-o, but wrong architecture PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/zend/lib/php_extensions/bcmath.so' - dlopen(/usr/local/zend/lib/php_extensions/bcmath.so, 9): no suitable image found. Did find: /usr/local/zend/lib/php_extensions/bcmath.so: mach-o, but wrong architecture in Unknown on line 0" Normal? – user968898 Dec 06 '11 at 10:44
  • Looks like Zend Server also has its own PHP version, while on the command line you are using the PHP version that comes with Mac OS X. Instead of calling plain `php`, you'll have to specify the full path to the PHP executable like this: `/path/to/zend/bin/php`. It'll probably use the right php-init without you having to use th `-c` parameter. – chiborg Dec 30 '15 at 12:53
  • You can also find ini files with `php --ini` – joelpittet Jun 29 '16 at 21:13