Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save james/132873 to your computer and use it in GitHub Desktop.
Save james/132873 to your computer and use it in GitHub Desktop.
At my new job, we play with maps and do crazy things with spacial data storage. We use the PostreSQL database with PostGIS on top.
Whilst I'm not particularly involved in the development of these things, I do require to have it up and running to develop on the same application. So my first day at my new job wasn't very fun when I had to spend half of it figuring out this PostGIS thing. I never liked Databases (I'm still pushing for flat file storage in our apps), and this new foreign language was very hard, especially seeing as I immediately placed as head of Macintosh support at the company (both of them).
There were a few solutions out there, and I got myself in a pickle switching between custom builds, ports and binaries, unsure about what was what, and which path to go down.
I've now done it a few times, and this is what I find works for me:
1. Install the ["Unix Compatability Frameworks"][1] ([Direct Link][2]) by [Kyng Chaos][3]
2. From the Kyng Chaos [Postres Page][4] install [PostreSQL][5] (You might as well install the startup item as well, although it hasn't always worked for me)
3. Then [PostGIS][6] from the same page
4. Start the Postgres server without restarting by typing the following into the terminal
<pre><code>sudo SystemStarter start PostgreSQL</code></pre>
5. If you don't have pgAdmin - go [grab it and install it][7] now.
6. Open up pgAdmin, and if you don't already have a localhost connection in the right sidebar - add a new connection with the host of 'localhost' and all other options default (user = postgres with no password)
7. In pgAdmin - connect to the localhost server, then right click on 'Login Roles' - the go to 'New Login Role'.
8. Assuming the DB isn't precious, I find it easiest if you create the user to have the same username as your OSX shortname, witht he same password, and all the Privileges ticked.
9. Right click on Databases, create a database where the owner is you, with the name that you want. Rest can be left blank.
10. Open a Terminal window, and run the following 3 commands (replacing yourdatabasename):
<pre><code>createlang plpgsql **yourdatabasename**
psql -d **yourdatabasename** -f /usr/local/pgsql/share/lwpostgis.sql
psql -d **yourdatabasename** -f /usr/local/pgsql/share/spatial_ref_sys.sql</code></pre>
11. Crack open a beer, and get coding. You've finished setting up.
And by Markdown's interesting interpretation of my write-up, that makes it a 1 step install!
If you have any problems, leave a comment. I'm hardly an expert, but if I'm so lucky as to actually know the problem, I'll update the guide to make it more concise.
If there are no comments, then I'm going to assume it's not because no-one's used this, but that it's so damn good, no-one had any problems.
[1]:http://www.kyngchaos.com/software/unixport/frameworks
[2]:http://www.kyngchaos.com/files/software/unixport/AllFrameworks.dmg
[3]:http://www.kyngchaos.com
[4]:http://www.kyngchaos.com/software/unixport/postgres
[5]:http://www.kyngchaos.com/files/software/unixport/pgsql-8.2.4-2.dmg
[6]:http://www.kyngchaos.com/files/software/unixport/postgis-1.2.1-2.dmg
[7]:http://www.pgadmin.org/download/macosx.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment