<?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>odwks &#187; postgres</title>
	<atom:link href="http://odwks.com/tag/postgres/feed/" rel="self" type="application/rss+xml" />
	<link>http://odwks.com</link>
	<description>&#62;  old dudes who know startups</description>
	<lastBuildDate>Tue, 02 Jun 2009 21:46:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>postgres install on OS X</title>
		<link>http://odwks.com/2008/10/postgresql-install-on-os-x/</link>
		<comments>http://odwks.com/2008/10/postgresql-install-on-os-x/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 07:49:05 +0000</pubDate>
		<dc:creator>Jon Hancock</dc:creator>
				<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://odwks.com/?p=18</guid>
		<description><![CDATA[I use postgres 8.3.x for ShellShadow.  My production and staging servers are linux but my dev and testing is done on OS X 10.5.x.  There exist &#8220;one-click installers&#8221; for postgres on OS X.  They are good and well worth using if that&#8217;s what you need.  I need finer control and like to use an install [...]]]></description>
			<content:encoded><![CDATA[<p>I use postgres 8.3.x for <a href="http://shellshadow.com" onclick="javascript:pageTracker._trackPageview ('/outbound/shellshadow.com');">ShellShadow</a>.  My production and staging servers are linux but my dev and testing is done on OS X 10.5.x.  There exist <a href="http://www.postgresql.org/download/macosx" onclick="javascript:pageTracker._trackPageview ('/outbound/www.postgresql.org');">&#8220;one-click installers&#8221;</a> for postgres on OS X.  They are good and well worth using if that&#8217;s what you need.  I need finer control and like to use an install as close to the same as what&#8217;s on my production machine.  So I install from source.  PostgreSQL installs quite easily from source but under OS X there are some little tricks that make your install cleaner and more like the production system.</p>
<p>Here is my recipe, tested under OS X 10.5.5 with postgres 8.3.4:</p>
<p><strong>Find an unused Group and User IDs.</strong> My system has two &#8220;login users&#8221;.  I want to add another user and need to find a number not in use.  The trick is to create a new user that does not show up on the OS X login dialog.   I found tips from here: http://macosx.com/forums/mac-os-x-system-mac-software/297377-add-user-can-not-seen.html<br />
<code><br />
&gt; sudo dscl . -list /Groups PrimaryGroupID<br />
&gt; sudo dscl . -list /Users UniqueID<br />
</code><br />
On my system, ID 503 is not in use, I&#8217;ll use this for my postgres Group and User IDs.  Note: OS X should give you an error on the following commands if you screw up and pick an ID already in use.</p>
<p><strong>Create OS X Group and User for postgres </strong>using ID 503 (substitute a different ID if this is taken):<br />
<code><br />
&gt; sudo dscl . create /Groups/postgres<br />
&gt; sudo dscl . create /Groups/postgres PrimaryGroupID 503<br />
&gt; sudo dscl . create /Groups/postgres RealName 'Postgres Admin Group'<br />
&gt; sudo dscl . create /Users/postgres<br />
&gt; sudo dscl . create /Users/postgres UniqueID 503<br />
&gt; sudo dscl . create /Users/postgres PrimaryGroupID 503<br />
# not sure if this next command is necessary.<br />
&gt; sudo dscl . create /Users/postgres NFSHomeDirectory /usr/local/pgsql<br />
&gt; sudo dscl . create /Users/postgres Password '*'<br />
&gt; sudo dscl . create /Users/postgres UserShell /bin/bash<br />
&gt; sudo dscl . create /Users/postgres RealName 'Postgres Admin User'</code></p>
<p><strong>Install postgres.</strong>  Download latest source from http://www.postgresql.org/ftp/source/ We&#8217;ll assume postgresql-8.3.4.tar.gz for this example.<br />
<code><br />
&gt; tar zxf postgresql-8.3.4.tar.gz<br />
# check your umask.  0002 or 0022 is good.<br />
&gt; umask<br />
&gt; cd postgresql-8.3.4<br />
&gt; ./configure<br />
&gt; make<br />
&gt; sudo make install<br />
&gt; sudo mkdir /usr/local/pgsql/data<br />
&gt; sudo chown postgres:postgres /usr/local/pgsql/data<br />
# switch to postgres user to initialize the database<br />
&gt; sudo su postgres<br />
&gt; /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data<br />
&gt; exit<br />
# setup the logs directory<br />
&gt; sudo mkdir /usr/local/pgsql/data/logs<br />
&gt; sudo chown postgres:postgres /usr/local/pgsql/data/logs<br />
&gt; sudo chmod 700 /usr/local/pgsql/data/logs<br />
# setup OS X launch script<br />
# paths assume you are still in the postgresql-8.3.4 source root<br />
&gt; cd contrib/start-scripts/osx<br />
&gt; sudo /bin/sh ./install.sh<br />
# to keep postgres from starting at OS X system start, edit /etc/hostconfig file:<br />
# change  POSTGRESQL=-YES-  =&gt;  POSTGRESQL=-NO-<br />
# to manually stop postgres<br />
&gt; sudo /Library/StartupItems/PostgreSQL/PostgreSQL stop<br />
# to manually start postgres<br />
&gt; sudo /Library/StartupItems/PostgreSQL/PostgreSQL start<br />
# add /usr/local/pgsql/bin to your PATH<br />
# in my ~/.bash_profile I have a line near the top which I changed to<br />
# PATH=$HOME/bin:/usr/local/pgsql/bin:$PATH:<br />
# after PATH change, exit shell and reopen or re-source .bash_profile<br />
# test if you can connect<br />
&gt; psql -Upostgres<br />
# type \q to quit</code></p>
<p><strong>Install pgcrypto.</strong>  Basic digest and crypto functions are not in the default compile.  You must install them separately.  Its best to do this now as the install requires the config options created from the core install above.<br />
<code><br />
# from postgresql-8.3.4/contrib/pgcrypto<br />
&gt; make<br />
&gt; sudo make install<br />
# The above install creates </code><code>/usr/local/pgsql/share/contrib/pgcrypto.sql which must be imported</code><code> to each schema (YOUR_DB_NAME) where the functions are used.<br />
&gt; psql -Upostgres -d <em>YOUR_DB_NAME</em> -f /usr/local/pgsql/share/contrib/pgcrypto.sql </code></p>
]]></content:encoded>
			<wfw:commentRss>http://odwks.com/2008/10/postgresql-install-on-os-x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
