Skip to content

Instantly share code, notes, and snippets.

@trentrichardson
Forked from giorgiofellipe/install_psql_php.sh
Last active November 7, 2016 20:57
Show Gist options
  • Save trentrichardson/a3f5cb47a66fd39a4a8b to your computer and use it in GitHub Desktop.
Save trentrichardson/a3f5cb47a66fd39a4a8b to your computer and use it in GitHub Desktop.
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" >> /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" >> /etc/php.ini
# Check if extension exists, again
php -m | grep pgsql
@trentrichardson
Copy link
Author

I noticed a few other things:

  • This script uses wget, which doesn't seem to be installed, so just brew install wget
  • Permission may be denied if writing to /etc/php.ini which seems to be the default location, but it is easy enough to manually update it with extension=pdo_pgsql.so and extension=pgsql at the bottom of the file.
  • Verify your version of Postgres if using Postgres.app (I had 9.4)
  • You should be able to remove the ~/php-src folder when you're done

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment