2

I am trying to make postgresql work with apache on my Mac OSX. I use homebrew to manage all my dev features, so I replace the default php version provided by apache and download a homebrew version, this part works really fine. The problem is when I want to install the postgresql extension..

I have done this :

  • brew install postgresql
  • brew install php55 --with-postgresql
  • brew install php55-pdo-pgsql

And then edit the /etc/apache2/httpd.conf file to replace LoadModule php5_module libexec/apache2/libphp5.so by LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so.

Then when I exec the phpinfo() command, I can't see the postgresql extension installed in the PDO section. I only have this : PDO config with phpinfo()

If anyone can help ;) Thank you all !

Possible solution : - First install all packets like this : brew install postgresql php55 php55-pdo-pgsql - Then brew reinstall php55 --with-postgresql

And it works.. I did this before (maybe not the same order) and it didn't work, I do not know why it works now !

Solution

When you watch the phpinfo() result, you should see something something like Loaded Configuration File and *Scan this dir for additional .ini files *. The thing is there is a global php.ini file and a .ini file per extension you install. The value for *Scan this dir for additional .ini files * is where the .ini file for the extension must be located. So just need to create a ext-pdo_pgsql.ini and load the extension with extension="path to your/pdo_pgsql.so" (mine was /usr/local/opt/php55-pdo-pgsql/pdo_pgsql.so).

And for the installation just need brew install php55 php55-pdo-pgsql postgresql

1 Answer 1

3
  1. Run php -m | grep pgsql to know if pgsql exists

  2. Follow the example in this answer. Jump to note if you have a problem with the instruction there corresponding to number 4 here.

  3. Enter ./configure --with-pdo-pgsql="path to postgres" and return. Mine is at "/usr/local/bin".

  4. Enter make && sudo make install and return.

  5. Add the extension to php.ini with sudo echo "extension=pdo_pgsql.so" >> path to php.ini. Find the path using php -i | grep php.ini

  6. That should install pdo driver for postgres

Note

It is possible that sudo make install doesn't work. It might be due to an OSX feature known as csrutil. Reboot your machine and hold down cmd + R. From the recovery inteface run csrutil disable from terminal.

Reboot again and perform the make install. Repeat same process as in the paragraph above to enable csrutil by running csrutil enable at the recovery interface's terminal.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your answer, I just can't find the directory in the second step. Is it under /usr/local/opt or something close?
Oh @ThomasCEDRINI. You can achieve 2 by using pear and following this answer.
Well .. I do not understand a thing about what is going on.. I've just done ‘brew reinstall php55 --with-postgresql‘ after installed php5, php5-pdo-pgsql and postgresql and surprise !!! It works ! I really do not understand why it didn't before
Ok that's good, I thing I've figured out how it works ;) I updated my post

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.