Reputation: 194
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.
Upvotes: 3
Views: 4674
Reputation: 105
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.
Upvotes: 3
Reputation: 582
Robert has solved this problem in this answer. stackoverflow.com/a/31884146 .
Basically the issue is the El Capitan's Rootless feature. Its needs to be disabled in recovery mode, perform the pecl install and that enable it back again .
For some reason , pecl did not install it into my php extensions directly so, I had to copy the mongo extension pecl generated from the local library to my php extension folder xampp files for it to work
Upvotes: 2