Mac OS X : Server 5.2 : How to rebuild PHP Postgresql modules ?

If you are using the Server.app 5.2 under El Capitan or older, you have issues with the Postgresql PHP  modules !

These modeules are compiled for php available under macOS sierra (PHP 5.6.25 – API=20131226). Under El Capitan, PHP 5.5.38 (API=20121212) is provided

and  when you run php, It complains about the API mismatch :

# php -v
PHP Warning:  PHP Startup: pdo_pgsql: Unable to initialize module
Module compiled with module API=20131226
PHP    compiled with module API=20121212

The workaround is to rebuild yourself these two modules.

You will find below how to proceed

1/ Boot into Recovery mode

Diable the System Integrity Protection into the Recovery mode :
$ csrutil disable

2/ Restart into normal mode and build php modules

Download :
– php 5.5.38 from http://www.php.net/
– postgresql93 from MacPorts

Build PHP Modules:

$ cd ext/pgsql
$ PHP_AUTOCONF=/opt/local/bin/autoconf PHP_AUTOHEADER=/opt/local/bin/autoheader PATH=$PATH:/opt/local/bin phpize
$ export PATH=$PATH:/opt/local/bin PGSQL_INCLUDE=/opt/local/include/postgresql93/ PG_CONFIG=/opt/local/lib/postgresql93/bin/pg_config
$ ./configure --prefix=/usr \
--includedir=/opt/local/include \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--with-pgsql=/opt/local/lib/postgresql93
$ make
$ make install
 
$ cd ../pdo_pgsql
$ PHP_AUTOCONF=/opt/local/bin/autoconf PHP_AUTOHEADER=/opt/local/bin/autoheader PATH=$PATH:/opt/local/bin phpize
$ ./configure --prefix=/usr \
--includedir=/opt/local/include \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--with-pdo-pgsql=/opt/local/lib/postgresql93
$ make
$ make install

And modify the /Library/Server/Web/Config/php/php.ini with new extensions :

extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/pgsql.so
extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/pdo_pgsql.so

3/ Restart into Recovery mode :

Enable the System Integrity Protection
$ csrutil enable

It is working for me.

Nicolas Portais
Author Photographer
http://www.mystockphoto.fr/
http://photos-art.pro/

Ce contenu a été publié dans Anglais, Computer / Technic / Technology, avec comme mot(s)-clé(s) , , , , , , , , , . Vous pouvez le mettre en favoris avec ce permalien.

2 réponses à Mac OS X : Server 5.2 : How to rebuild PHP Postgresql modules ?

  1. agenda sbobet dit :

    Way cool! Some verry valid points! I appreciate you writing this post pluѕ the гest off
    the websitе іs extremely good.

  2. tinhchathau.com dit :

    It’s awesome to visit tһis web site ɑnd reading the views of аll mates on the
    topic of this piece оf writing, while I am аlso eager
    of getting experience.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Captcha (solve the arithmetic equation) * Time limit is exhausted. Please reload CAPTCHA.