Any help would be great. I've been stuck on this for hours. I'm trying to install Mongo to work with PHP on a Mac. I have Pear/pecl installed and working. When I call sudo pecl install mongo, everything looks like it's compiling/building successfully, but at the end I get this message.
Build process completed successfully Installing '/usr/lib/php/extensions/no-debug-non-zts-20121212/mongo.so' ERROR: failed to write /usr/lib/php/extensions/no-debug-non-zts-20121212/mongo.so (copy(/usr/lib/php/extensions/no-debug-non-zts-20121212/mongo.so): failed to open stream: Operation not permitted)
And the mongo.so never gets written. Can someone help? I'm using MAMP on Mac OSX El Capitan.
I've solved this problem by changing extension_dir in php.ini.
Create a local extension dir and copy your existing extensions into
mkdir -p /usr/local/lib/php/extensions
cp /usr/lib/php/extensions/no-debug-non-zts-20121212/* /usr/local/lib/php/extensions/
Update your php.ini, change the extension_dir and enable mongo:
extension_dir = "/usr/local/lib/php/extensions/"
extension=mongo.so
Now the extension dir is writeable you can copy the mongo.so there.
Here's how to compile a mongo.so
wget http://pecl.php.net/get/mongo
tar xzvf mongo
cd mongo-1.6.12
phpize
./configure --with-php-config=/usr/bin/php-config --with-mongo-sasl=no
make
You can find the compiled library in .libs folder: .libs/mongo.so
Copy it to extensions dir
cp .libs/mongo.so /usr/local/bin/php/extensions/
Finally, you can check whether it's working or not, by typing php -m | grep mongo in the command line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With