Cannot install PHP SDK on Mac OS

#1

Hi,

I’m trying to install PHP SDK on Mac OS.

I’ve already installed libcouchbase using brew, but pecl keeps telling me that it requires libcouchbase.

When I run

sudo pecl install couchbase

I get

configure: error: the couchbase extension requires libcouchbase
ERROR: `/private/tmp/pear/temp/couchbase/configure’ failed

How can I fix this? Furthermore, the documentation is really poorly written. None of my teammates understood it. None of them were able to install the sdk and run it at their first attempt. Is there a plan to improve it?

#2

Hello,

Which version of OS X are you running?
Are you using the php shipped with OS X?

#3

Hi pvarley,

I’m running Mac OS El Capitan (10.11.1).

I’m using php 5.5.18 with MAMP.

Thanks,
Moon

#4

Bump…

I’m using a virtualbox for dev, but sometimes it makes things easier if I can have a local version of couchbase as well.

documentation on php sdk on github does not work on mac os.
documentation on libcouchbase on github does not work on mac os.

Couchbase is at version 4 now. I think it should be easy to install SDK at this point.

#5

Found the cause.

After I confirmed that the lib files are in /usr/local/lib, I suspected that the installation was not locating C standard library directory.

It sounds like it is related to brew (when you upgrade your os, it seems like there is a linking issue).

Running xcode-select --install fixed my issue.

#6

After successfully installing and running Couchbase on my Linux box, I’ve decided to install Couchbase and the PHP SDK on my Mac because I’m more productive on it. When I use PECL on the Mac, it fails with the following, just as it did for others in another past thread:

mkdir fastlz/.libs
mkdir: fastlz: No such file or directory
make: *** [fastlz/fastlz.lo] Error 1
ERROR: `make’ failed

So, I got and get the tar for php5.6.22 and recompiled that and it’s complied now in the /usr/bin. I now have the source files for future use and an updated php setup.

I then downloaded and decompressed the git for Couchbase. I followed the usual instructions from the PHP website (http://php.net/manual/en/install.pecl.phpize.php). I figured that I’d end up with a .so file at the end and move that somewhere, then edit the appropriate php.ini file.

For starters, it wouldn’t let me run it as a normal user. I’m looking over the permissions and the files are owned by root and staff group members only have read access. Not sure if I should do a mass chown on them. I went ahead and ran phpize under sudo and seemed to work fine.

When make is run, I get the following error:

cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/couchbase.so -bundle .libs/bucket.o .libs/cas.o .libs/cluster.o .libs/couchbase.o .libs/docfrag.o .libs/exception.o .libs/get.o .libs/unlock.o .libs/metadoc.o .libs/opcookie.o .libs/paramparser.o .libs/transcoding.o .libs/touch.o .libs/remove.o .libs/subdoc.o .libs/store.o .libs/n1ql.o .libs/http.o .libs/counter.o .libs/durability.o .libs/n1ix_spec.o .libs/n1ix_list.o .libs/n1ix_create.o .libs/n1ix_drop.o fastlz/.libs/fastlz.o -L/usr/local/lib -lcouchbase -Wl,-rpath -Wl,/usr/local/lib
duplicate symbol _oldformat_t in:
.libs/bucket.o
.libs/get.o
.
.

.
.
duplicate symbol _compression_t in:
.libs/bucket.o
.libs/n1ix_drop.o
ld: 52 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [couchbase.la] Error 1

My question, is it possible to plop the git contents inside the php source tree, and from the base of the php source, run a ./configure --enable-couchbase like you can with other extensions (or does the .so need to be compiled for this --enable command)? I’m just looking over the source tree and not sure where to match up what from the contents of the git right now…

Historically, I’ve relied on PECL for this kind of work.

Also, when I followed the instruction from the README.md file, when I ran the ./config, it told me that --enable-couchbase is an unrecognized command.

Thanks.

#7

@patrickwalker have you tried to install beta?

pecl install couchbase-2.2.0beta3
#8

I’ll gave it a shot but it gives me the same error as above regarding the duplicate symbols.

#9

I’ve just rebuilt it on my mac. Got the same issue. I will update this topic when I fix it

1 Like
#10

The master branch should be good now

#11

It seems to have compiled just fine. I’m assuming that the .so file is the only one required to be in the extensions folder in PHP or do the other files need to be present in the same folder as couchbase.so?

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20131226/
cp: /usr/local/lib/php/extensions/no-debug-non-zts-20131226/#INST@70787#: Permission denied
make: *** [install-modules] Error 1

I noticed that the version of php Apache was using was not the same as the compiled version. I have two now, one in /usr/bin and the newer on in /usr/local/bin. I guess Mac OS prevents me from linking across /usr/local but I renamed /usr/bin/php to php5.5.34. Now, php -v shows 5.6.22…

Having all sorts of issues like the ability to ln my new version of php into /usr/bin is not being allowed. Also, when I do php -i, it says there’s not config file being loaded…

I believe this is a PHP configuration issue now.

#12

For pecl you could check the output of pecl config-show which have to reference to the correct php version. And if when you are building from git, you can also use ./configure --with-couchbase --with-php-config=/usr/local/bin/php-config to make sure it will pick up everything right. Also upgrades php through brew upgrade might install new php version into different directory, so that the extension might be left in the older copy.

#13

I built php straight from source and not through brew. peel config-show is targeting 5.6.22.

I just recompiled the git as you suggested and still get the same fail to copy error. Copied the lai and so files straight into my extensions directory. No effect. I verified with php -v that the extension path is correctly pointing to their location.

I need to remove/change /usr/bin/php (5.5.34) but the OS won’t let me. Not sure I want to boot into recovery and disable the protection scheme.

#14

Yes, .so file is enough. But also libcouchbase.so should be accessible. Also make sure that in INI file JSON extension goes before couchbase

#15

Not sure it matters because PHP is ignoring the INI files completely. I’m now stuck in configuration hell because Apple prevents people from tampering with locations like /usr.

#16

what does php --ini says?

#17

It’s pointing to /usr/local/lib, and because of that I moved php.ini.default but hasn’t had any effect for me that I can see.

I did disable csr and replace /usr/bin/php with the newer /usr/local/bin/php version.

#18

Turns out I had way too many php.ini files floating around. The shipped Apple version(s), the versions I obtained when I complied PHP then another set when I used Homebrew to install php (third time’s a charm).

Once I cleaned those up, and made sure both php and php-fpm were reading from the correct file, then everything began to work. PHP is showing the correct versions all around.

I managed to replace the module entry in the /etc/apache2/httpd.conf with the full path and filename to the latest module version that homebrew installed (old one is in /usr/libexec/apache2, which is locked by Apple unless csr is disabled, and my compilation attempt didn’t make one, so that’s why Apache kept spitting out version 5.5.34). Changing that line got it working in Apache.

I’d prefer to be using nginx but having problems with php-fpm working with it (don’t feel like messing around with more conf files for a little while).

Couchbase also shows up when I do a php -i:

couchbase

couchbase support => enabled
extension version => 2.2.0beta3
libcouchbase runtime version => 2.6.0 (git: 1bd–snip–f3)
libcouchbase headers version => 2.6.0 (git: 1bd–snip–f3)

I hope this will help others in the future.

Thank you for your help and patience, Sergei.