Search code examples
phpmacospostgresqlpdophp-pgsql

Postgres.app pdo_pgsql pgsql installed but php couldn't find module. MAC OS X


I have problem with Postgres.app. Postgres.app is running without problems.

In my phpinfo() I can see.

PDO drivers => mysql, odbc, sqlite, pgsql

If I run commat php -m I can see:

...
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite

Everything seems to be installed and prepared. But If I run my project, It says.

could not find driver

I've installed pgsql and pdo_pgsql by following link https://alistairphillips.com/apple/osx/php-pdo-pgsql/

PS: I also have

extension=pdo_pgsql.so
extension=pgsql.so

Solution

  • After install new OS X El Capitan I have to: Please note that I've installed http://postgresapp.com/ I highly recommend this.

    • Install PHP5 from http://php-osx.liip.ch/
    • Download PHP source packages (for my version) from http://php.net/downloads.php
    • Unpack sources and do following:
      • cd php-{version}/ext/pdo_pgsql
      • phpize
      • ./configure --with-pdo-pgsql="/Applications/Postgres.app/Contents/Versions/9.4"
      • sudo make && make install
    • Install pgsql:
      • cd php-{version}/ext/pgsql
      • phpize
      • ./configure --with-pgsql="/Applications/Postgres.app/Contents/Versions/9.4"
      • sudo make && make install

    Or I've modified one script I've found. You can download and use it from https://gist.github.com/FilipLukac/b460b233857a65e1342a

    • Set up PHP_VERSION variable
    • Set up PHP_INI variable (php.ini file location path)
    • Run ./install.sh

    And then restart apache sudo apachectl -k restart