<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Motion Standing Still &#187; Database</title>
	<atom:link href="http://www.motionstandingstill.com/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.motionstandingstill.com</link>
	<description>high performance ruby on rails</description>
	<lastBuildDate>Sun, 11 Jul 2010 03:46:07 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting up Postgres + Postgis on OSX</title>
		<link>http://www.motionstandingstill.com/setting-up-postgres-postgis-on-os/2008-12-18/</link>
		<comments>http://www.motionstandingstill.com/setting-up-postgres-postgis-on-os/2008-12-18/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 23:22:49 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Features]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=217</guid>
		<description><![CDATA[I've just installed Postgresql for the first time on my MacBook - it was a pain and wasn't as simple as it should have been.  This is what I did to get it working.


No related posts.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Even though I&#8217;m stupidly busy with my current work I&#8217;ve started getting ready for my next gig.  As this has ment installing Postgresql on my Macbook for the first time I thought I&#8217;d quickly share the solution to the pain I went through in getting it to work.</p>
<p style="text-align: justify;">I received two suggestions for the &#8216;best install method&#8217;, firstly MacPorts and then later pre-compiled dmg&#8217;s from <a href="http://www.kyngchaos.com/wiki/software:postgres" target="_blank" class="broken_link">Kyng Chaos</a>.  I already use ports extensively making that choice easy for me &#8211; I like being able to  uninstall things if they don&#8217;t work to well and was concerned the dmg option wouldn&#8217;t allow me to.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> port <span style="color: #c20cb9; font-weight: bold;">install</span> postgresql83 postgresql83-doc postgresql83-server postgis</pre></div></div>

<p style="text-align: justify;">I then added the following to my path in ~/.zshrc so I could actually run things</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83<span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

<p style="text-align: justify;">and started the server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> launchctl load <span style="color: #660033;">-w</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>org.macports.postgresql83-server.plist</pre></div></div>

<p style="text-align: justify;">All seemed to be fine and dandy as I could connect with <a href="http://www.pgadmin.org/" target="_blank">pgAdmin</a>.  I quickly discovered that I needed to create a user with the same login as my osx login when I tried creating a test db.</p>
<p style="text-align: justify;">Next I tried restoring my client&#8217;s db dump and it barfed big time.  As I&#8217;ll be working on some mapping software I&#8217;d installed the PostGIS package which seems to have failed to link up with Postgres properly.   I was getting the follow missing library error:</p>
<blockquote style="text-align: justify;"><p>could not load library /usr/lib/postgresl/liblwgeom.so.1.3</p></blockquote>
<p style="text-align: justify;">Obviously it&#8217;s looking in the wrong place for a start, so I setup a LIBDIR export in my profile to get over that problem and restarted the server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LIBDIR</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83</pre></div></div>

<p style="text-align: justify;">That still didn&#8217;t solve the problem though as I don&#8217;t have a file by that name on my system, I do however have liblwgeom.1.3.so which looked to be the same thing.  Pretty annoying, but easily solved with a symlink.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-snf</span> liblwgeom.1.3.so liblwgeom.so.1.3</pre></div></div>

<p style="text-align: justify;">Then the backup restored like a chalm.</p>
<p style="text-align: justify;">To get Rails talking to Postgresql I needed to install the postgres adapter gem appropriately called &#8216;postgres&#8217;.  I didn&#8217;t expect that to work straight off though as I&#8217;d installed postgresql with ports and the gem by default would be looking in the wrong place for it.  I was correct, but I also received an additional error complaining about the architechture not being specified &#8211; I needed to tell it I wanted i386.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">ARCHFLAGS</span>=<span style="color: #ff0000;">&quot;-arch i386&quot;</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> postgres <span style="color: #660033;">--</span> <span style="color: #660033;">--with-pgsql-include-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>postgresql83l <span style="color: #660033;">--with-pgsql-lib-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postgresql83<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p style="text-align: justify;">I gropped around for a bit trying to figure out the correct way of letting it know and eventually found the above solution on <a href="http://codesnippets.joyent.com/posts/show/1441" target="_blank">code snippets</a>.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/setting-up-postgres-postgis-on-os/2008-12-18/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.498 seconds -->
