Skip to content

Instantly share code, notes, and snippets.

@demitri
Created July 21, 2015 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demitri/b1d87c15891b6d147da6 to your computer and use it in GitHub Desktop.
Save demitri/b1d87c15891b6d147da6 to your computer and use it in GitHub Desktop.
Installing PostgreSQL from source

These are directions written a few years ago to help SciCoder students install PostgreSQL from source. It might be a little out of date, but could still be useful. And the Markdown needs updating.

The following instructions will show you how to install PostgreSQL from source. Although other methods are available, I would like you to follow these directions. The directions are applicable to both Mac and Linux platforms. In each case, you will be running the installation from the terminal command line.

[b]Mac Users[/b] We need to make sure that a few settings are correct.

  • Are you running a 64-bit machine? If no, skip down to step one below. You can check by entering the following on the command line:

[code]sysctl hw | grep 64bit[/code]

If the last number is 1, then your machine is 64-bit, if 0, then it's 32-bit.

  • We need to ensure that we link against a 64-bit version of python during this build. The Enthought distribution is 32-bit and may be the default on your machine. Enter the following on the command line, depending on your shell:

bash shell: [code]export LDFLAGS="-F/System/Library/Frameworks" export LDFLAGS_SL="-F/System/Library/Frameworks" export PATH=/System/Library/Frameworks/Python.framework/Versions/Current/bin/:$PATH [/code]

tcsh shell: [code] setenv LDFLAGS "-F/System/Library/Frameworks" setenv LDFLAGS_SL "-F/System/Library/Frameworks" setenv PATH "/System/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}" [/code]

[b]Installing PostgreSQL[/b]

  1. Download the source package from the link below. Make sure to select the "source code" link in the source code section - do not select your platform.

[url]http://www.postgresql.org/download/[/url]

Download the latest distrubution (8.4.4 as of this writing). Download the package ending in "bz2". For this instuction set, we'll assume the filename is "postgresql-8.4.4.tar.bz2"; adjust the directions as appropriate if there is an update.

  1. Place the downloaded file into a new directory. I recommend creating a directory here (if it doesn't already exist on your system): /usr/local/source. Place the downloaded file into this directory.

  2. Uncompress the file with this command:

[code]tar -xjf postgresql-8.4.4.tar.bz2[/code]

This creates a new directory called "postgresql-8.4.4"; "cd" into that.

  1. Enter the following command inside the new direcory:

[code]./configure --prefix=/usr/local/postgresql-8.4.4 --with-python[/code]

This should check your system, hopefully without errors.

  1. Enter "make" on the command line. When this finishes, type the following to install the database into your system.

[code]sudo make install[/code]

  1. Go to where postgres was installed:

[code]cd /usr/local[/code]

and enter this:

[code]ln -s postgresql-8.4.4 postgresql[/code]

  1. The programs are installed in /usr/local/postgresql/bin. You need to add this path to your PATH environment variable.

bash users: add these lines to your .bashrc file:

[code]PATH=/usr/local/postgresql/bin:$PATH export PATH[/code]

tcsh users: add this line to your .tcshrc file:

[code]setenv PATH "${PATH}:/usr/local/postgresql/bin"[/code]

If you are not sure which shell you are running, enter:

[code]echo $SHELL[/code]

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