Installing PostgreSQL from source on my Mac

In order to build PostgreSQL from source on my MacBook Pro running El Capitan, I first downloaded the git repo:

git clone git://

I then built it:

cd postgresql
sudo make install

This will install the binaries to the default location of “/usr/local/pgsql”.

I already had a user called “_postgres” in my /etc/passwd file, so I configured to run PostgreSQL as this user:

sudo mkdir /usr/local/pgsql/data
sudo mkdir /usr/local/pgsql/log
sudo chown postgres /usr/local/pgsql/data
sudo chown postgres /usr/local/pgsql/log
sudo -u _postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

I added a file called “org.postgresql.server.plist” to the directory /Library/LaunchDaemons. The content of the file is below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Make sure to modify it’s ownership to be admin:

sudo chown root:admin /Library/LaunchDaemons/org.postgresql.server.plist

Then the server can be started using the “launchctl” command:

sudo launchctl load /Library/LaunchDaemons/org.postgresql.server.plist

Leave a Reply