Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install PHP PGSQL extensions on Mac OS X Yosemite (change PHP_VER with your PHP version)
PHP_VER="5.5.14"
# Check if extension exists first
php -m | grep pgsql
# Update brew and install requirements
brew update
brew install autoconf
# Download PHP source and extract
mkdir -p ~/src; cd ~/src
wget -c http://br1.php.net/distributions/php-$PHP_VER.tar.bz2
tar -xjf php-$PHP_VER.tar.bz2
# Go to extension dir and phpize
cd php-$PHP_VER/ext/pdo_pgsql/
phpize
# Configure for Postgress.app
# Use just "./configure" for brew version
./configure --with-pdo-pgsql="/Library/PostgreSQL/9.3/"
make
sudo make install
# Add extension to php.ini
sudo echo "extension=pdo_pgsql.so" >> /private/etc/php.ini
# Go to extension dir and phpize
cd php-$PHP_VER/ext/pgsql/
phpize
# Configure for Postgress.app
# Use just "./configure" for brew version
./configure --with-pgsql="/Library/PostgreSQL/9.3/"
make
sudo make install
# Add extension to php.ini
sudo echo "extension=pgsql.so" >> /private/etc/php.ini
# Check if extension exists, again
php -m | grep pgsql
@cristiancvanega

This comment has been minimized.

Copy link

commented Apr 2, 2015

thanks.

@leehicks

This comment has been minimized.

Copy link

commented Apr 7, 2015

Need to change line 29 to either go up a couple of directories or switch "../pgsql" due to where the "cd" places you on line 16.

@trentrichardson

This comment has been minimized.

Copy link

commented Apr 14, 2015

Thanks @giorgiofellipe! For anyone trying to get up and running with this script for the built in php on Yosemite and the Postgres.app I had to make a few changes:

  • Point to Postgres.app installation
  • Point it to php.ini in /etc directory to enable the extension
  • As @leehicks mentioned change the cd to "../pgsql".
PHP_VER="5.5.14"

# Check if extension exists first
php -m | grep pgsql

# Update brew and install requirements
brew update
brew install autoconf

# Download PHP source and extract
mkdir -p ~/php-src; cd ~/php-src
wget -c http://br1.php.net/distributions/php-$PHP_VER.tar.bz2
tar -xjf php-$PHP_VER.tar.bz2

# Go to extension dir and phpize
cd php-$PHP_VER/ext/pdo_pgsql/
phpize

# Configure for Postgress.app
./configure --with-pdo-pgsql="/Applications/Postgres.app/Contents/Versions/9.4"
# Use just "./configure" for brew version
# ./configure --with-pdo-pgsql="/Library/PostgreSQL/9.3/"
make
sudo make install

# Add extension to php.ini
# sudo echo "extension=pdo_pgsql.so" >> /private/etc/php.ini
sudo echo "extension=pdo_pgsql.so" >> /etc/php.ini

# Go to extension dir and phpize
cd ../pgsql/
phpize

# Configure for Postgress.app
./configure --with-pgsql="/Applications/Postgres.app/Contents/Versions/9.4"
# Use just "./configure" for brew version
# ./configure --with-pgsql="/Library/PostgreSQL/9.3/"
make
sudo make install

# Add extension to php.ini
# sudo echo "extension=pgsql.so" >> /private/etc/php.ini
sudo echo "extension=pgsql.so" >> /etc/php.ini

# Check if extension exists, again
php -m | grep pgsql

Also slightly off topic but if you're trying to get all this setup for CakePHP 3 and need the Intl extension installed too here are some instructions within this Symphony setup tutorial: http://dab.io/posts/getting-started-with-symfony-on-yosemite.html Just do the Xcode install step then skip down the the Intl step.

@annettedorothea

This comment has been minimized.

Copy link

commented Jun 12, 2015

thanks for sharing

@expalmer

This comment has been minimized.

Copy link

commented Jul 20, 2015

Thanks for sharing !

@deK1tErminAte

This comment has been minimized.

Copy link

commented Jul 24, 2015

thanks for sharing

i had to make some changes to get this working:

set my php version to

  • PHP_VER="5.5.20"

install wget manually, because the first run of the script failed

  • brew install wget

create also a new php.ini, because there was no php.ini before and $ php --ini gives a

Configuration File (php.ini) Path: /etc
Loaded Configuration File:         (none)
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed:      (none)
  • sudo cp /etc/php.ini.default /etc/php.ini

dont forget to restart apache ;)

  • sudo apachectl restart
@dankarran

This comment has been minimized.

Copy link

commented Sep 11, 2015

Thanks for sharing this process!

@johnt1000

This comment has been minimized.

Copy link

commented Sep 12, 2015

Thanks for sharing!

@giordhano

This comment has been minimized.

Copy link

commented Sep 25, 2015

Thanks, this works perfectly for me !

@maxim-dev

This comment has been minimized.

Copy link

commented Sep 30, 2015

this works, thanks!

@rajrsingh

This comment has been minimized.

Copy link

commented Dec 18, 2015

sudo make install fails on OS X 10.11.1
Could it have something to do with https://en.wikipedia.org/wiki/System_Integrity_Protection?

@henryezeanya

This comment has been minimized.

Copy link

commented Jun 5, 2016

Please, what directory location do I place the script to be able to run it on OS X Elcapitan (10.11).

Thanks.

@azizultex

This comment has been minimized.

Copy link

commented Jun 9, 2016

I am on EI Capitan. to show an error:

$ sudo make install
Password:
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST@42992#: Operation not permitted
make: *** [install-modules] Error 1

@azizultex

This comment has been minimized.

Copy link

commented Jun 9, 2016

Ok. Works now! Just copied and pasted from here. https://gist.github.com/doole/8651341

@rodrigowerlin

This comment has been minimized.

Copy link

commented Sep 12, 2016

Thanks for this process, it helped me fully! ;)

@nbap

This comment has been minimized.

Copy link

commented Nov 17, 2016

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.