Skip to content

Instantly share code, notes, and snippets.

@shanna
Created September 6, 2016 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shanna/9f97a6792c455fb4bfc298e13cc270b8 to your computer and use it in GitHub Desktop.
Save shanna/9f97a6792c455fb4bfc298e13cc270b8 to your computer and use it in GitHub Desktop.
Postgres install from source on OSX when homebrew won't give you a specific version.
#!/usr/bin/env bash
set -e
# Homebrew homebrew/versions was broken when I went to install postgres.
# This shell script just documents my install from source.
release=9.4.6
prefix=$HOME/local
mkdir -p $prefix
cd $prefix
curl -# https://ftp.postgresql.org/pub/source/v${release}/postgresql-${release}.tar.gz | tar -zxvf -
cd postgresql-$release
# If this fails you may need to install openssl with homebrew.
CFLAGS='-arch x86_64 -I/usr/local/opt/openssl/include' LDFLAGS='-arch x86_64 -L/usr/local/opt/openssl/lib' ./configure --prefix=$HOME/local/postgresql --with-openssl --with-libs=/usr/local/lib --with-includes=/usr/local/include
# postgres
make
make install
# postgres-contrib
cd contrib
make
make install
cd $prefix
rm -rf postgresql-$release
echo "Add ${prefix}/postgresql/bin to \$PATH environment variable."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment