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://git.postgresql.org/git/postgresql.git I then built it: cd postgresql ./configure gmake 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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>KeepAlive</key>
  <true/>
  <key>Label</key>
  <string>org.postgresql.server</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/pgsql/bin/postgres</string>
    <string>-D</string>
    <string>/usr/local/pgsql/data</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>UserName</key>
  <string>_postgres</string>
  <key>WorkingDirectory</key>
  <string>/usr/local/pgsql</string>
  <key>StandardOutPath</key>
  <string>/usr/local/pgsql/log/server.log</string>
  <key>StandardErrorPath</key>
  <string>/usr/local/pgsql/log/server.log</string>
</dict>
</plist>
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