Jan 31, 2016

Issues when reinstall phpbrew on OS X EI Capitan

Annoying things coming one by one.

After update to EI Capitan, I found that all my configuration for linking phpbrew with system apache lost. Resolved quickly, but...

After did 'brew update' today, phpbrew poisoned by new version of icu4 installed by homebrew. It was built with 54, but now version is 56, so it always complained about could not find the so file...even when change a directory, just because the 'source ~/.phpbrew/bashrc' in my own .bashrc.

At last, I decided to CLEAN all this messed stuff up, via... rm -rf ~/.phpbrew.

And prepared to reinstall it, not be aware of what was waiting for me....

Issue#0 operation not permistted when 'sudo chmod -R oga+rw /usr/libexec/apache2'
  root cause: Apple's system integrity protection
  solution: reboot, cmd+r to enter repair mode, open terminal, execute 'csrutil disable; reboot'
  reference: http://stackoverflow.com/questions/32659348/operation-not-permitted-when-on-root-el-capitan-rootless-disabled

Issue#1 Cannot find OpenSSL's <evp.h>
  root cause: openssl header file missing
  solution: $phpbrew ...+openssl=/usr/local/opt/openssl
refernce: https://github.com/phpbrew/phpbrew/issues/612

Issue#2 Cannot find OpenSSL's libraries
  root cause: openssl lib path missing
  solution: $sudo ln -s /usr/local/opt/openssl /usr/lib/openssl
  reference: https://github.com/phpbrew/phpbrew/issues/418

Issue#3 Cannot locate header file libintl.h
  root cause: gettext header file missing
  solution: $brew link icu4c gettext --force
  refernce: https://github.com/phpbrew/phpbrew/issues/453

Issue#4 symbols not match when php build sis linking:
  Undefined symbols for architecture x86_64:
  "_PKCS5_PBKDF2_HMAC", referenced from:
      _zif_openssl_pbkdf2 in openssl.o
  "_TLSv1_1_client_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_1_server_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_2_client_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_2_server_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  root cause: ???
  solution: run following command before phpbrew install: $export LDFLAGS="/usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib"
  referenc: http://weaponsgradecode.com/2015/10/12/installing-php-5-6-14-with-phpbrew-and-homebrew-on-os-x-el-capitan/

Finally, my new php-5.6.17 was installed under phpbrew with the following command:
phpbrew install 5.6.17 +default +mysql +pdo +apxs2=/usr/sbin/apxs +dba +filter +gettext +iconv +mcrypt +openssl=/usr/local/opt/openssl +posix +session +soap +sqlite +gd -- --with-gd=shared --enable-gd-natf --with-jpeg-dir=/usr --with-png-dir=/usr

Final thought: it came to my mind at last that homebrew suggest similar method as LDFLAGS config when install some module like openssl. So it might be a compile flag setting which could solve the openssol <evp.h> issue....but anyways, I don't want to try that myself.