Enabling PostgreSQL support in PHP on Mac OS X
The PHP version that comes bundled with OS X doesn't include PostgreSQL. You'll have to compile the extension yourself. Here are some instructions:
- Find your version of PHP:
php -v
. - Download the version of PHP that matches yours:
curl -O http://us.php.net/distributions/php-5.3.3.tar.gz
. (This example downloads PHP 5.3.3 but this must match your version) - Extract the archive you downloaded:
tar -xzvf php-5.3.3.tar.gz
- Change to the PostgreSQL's extension directory:
cd php-5.3.3/ext/pgsql/
- Type
phpize
. - Type
./configure
. - Type
make
. - Type
sudo make install
. - Add the extension to you
php.ini
file by addingextension=pgsql.so
. (You may already have done this) - Restart Apache.
Update for OS X Mountain Lion
Apple has removed autoconf
from the newer versions of XCode so the procedure above will fail at #5. To solve that problem:
- Type
/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
. - Type
sudo chown -R $USER /usr/local/Cellar
. - Type
brew update
. - Type
brew install autoconf
.
That should install autoconf
and allow you to install the module using the instructions above.
Install PHP with Postgresql on MAC using homebrew
I found a way to fix the problem. I installed postgresql with homebrew (even if it was already installed on my computer), then installed php5.6 with the following command line :
brew install php56 --without-mysql --without-apache --with-postgresql
Then I uninstall postgresql with homebrew
brew uninstall postgresql
And finally I installed php5.6 pdo-pgsql
brew install php56-pdo-pgsql
Hope it will help !
PHP not loading postgresql extensions ( mac os x)
Solution
The version i had wasn´t built with the --with-postgresql
option in brew so i uninstalled the php56 and then reinstalled it with the option mentioned before following all the instructions
https://github.com/Homebrew/homebrew-php
You can get the post installation insctructions with brew info php56
in my case.
With the php built with postgresql you don´t need to add the pgsql.so and pdo_pgsql.so extensions in the php.ini file.
Related Topics
Variable Position in Comparision in PHP
Double Not (!!) Operator in PHP
Symfony 2 Entitymanager Injection in Service
Wamp/MySQL Errors Not in Correct Language
How to Get Final Url After Following Http Redirections in Pure PHP
Error 403 in Loading Resources Like CSS and Js in My Index.Php
PHP Composer Behind Http Proxy
How to Detect the Browser with PHP or JavaScript
Which Tokens Can Be Parameterized in Pdo Prepared Statements
Cakephp-3.X: How to Change the Data Type of a Selected Alias
Loop Code for Each File in a Directory
How to Force Laravel Project to Use Https for All Routes
999 Error Code on Head Request to Linkedin
Highlight the Word in the String, If It Contains the Keyword
Logging in to Joomla 1.5 Using External Form (Not Within Joomla Folder, But on Same Server)