<?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>eXpand yOur cReativity &#187; port</title>
	<atom:link href="http://blog.bhushangahire.net/tag/port/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bhushangahire.net</link>
	<description></description>
	<lastBuildDate>Thu, 05 Jan 2012 07:17:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Installing PostgreSQL on Snow Leopard 10.6</title>
		<link>http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=installing-postgresql-on-snow-leopard-10-6</link>
		<comments>http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 08:41:59 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[MAC Tiger]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=152</guid>
		<description><![CDATA[Installing PostgreSQL 8.3 First, you’ll need to install Xcode if you haven’t already. This is available on the Snow Leopard DVD in the Optional Installs directory. Second, if you aren’t already using it, download Mac Ports for Snow Leopard and install it. Mac Ports has come a long way in the last few years and [...]]]></description>
			<content:encoded><![CDATA[<div class="entry">
<h2>Installing PostgreSQL 8.3</h2>
<p>First, you’ll need to install Xcode if you haven’t already. This is available on the Snow Leopard DVD in the Optional Installs directory.</p>
<p>Second, if you aren’t already using it, download <a href="http://distfiles.macports.org/MacPorts/MacPorts-1.8.0-10.6-SnowLeopard.dmg">Mac Ports for Snow Leopard</a> and install it. Mac Ports has come a long way in the last few years and will make your life much easier.</p>
<p>Once those are installed, run the following command:<br />
<code>sudo port install postgresql83 postgresql83-server</code></p>
<h2>Setup Your First Database</h2>
<p>At the very end of the install it tells you how to setup your first database:</p>
<p><code>sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb</code><br />
<code>sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb</code><br />
<code>sudo su postgres -c '/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'</code></p>
<p>You’ll also want to setup Postgres to auto-run as a server on start up.</p>
<p><code>sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist</code></p>
<p>If you want to start it right now, you can either reboot or do the following:</p>
<p><code>sudo su postgres -c '/opt/local/lib/postgresql83/bin/postgres -D /opt/local/var/db/postgresql83/defaultdb'</code></p>
<h2>Make psql Available from the Command Line</h2>
<p>The executable files for PostgreSQL get shoved into a non-standard place (just like MySQL), so you’ll need to edit the default profile.</p>
<p><code>sudo vi /etc/profile</code></p>
<p>You can also do this using <code>sudo mate /etc/profile</code> if you aren’t comfortable in VI.</p>
<p>The <code>PATH=</code> line needs to be changed to include the PostgreSQL bin directory.</p>
<p>Mine was <code>PATH="/opt/local/bin:$PATH"</code> and is now:</p>
<p><code>PATH="/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql83/bin:$PATH"</code></p>
<p>If you open a new terminal window you can now type <code>psql</code> and it will find it.</p>
<h2>Create a New User and Database</h2>
<p>By default, PostgreSQL creates a <em>postgres</em> user for you. However, it’s not good practice to use the default and it’s a pain in the ass. Let’s just create a new database user to make it easier.</p>
<p><code>createuser --superuser macusername -U postgres</code></p>
<p>You need to change <code>macusername</code> to your mac username. This will make your life ALOT easier. Trust me here.</p>
<p>Next, create your database:</p>
<p><code>createdb my_database</code></p>
<h2>Installing the PostgreSQL Ruby Gem</h2>
<p>Unlike the MySQL driver, we don’t need to pass the ARCHFLAGS variable as 64 bit. PostgreSQL comes with both 32 and 64-bit versions. Yeah!</p>
<p><code>sudo gem install postgres-pr</code></p>
<p>Per Tom’s comment below, we should be using the native driver for better performance.</p>
<p><code>sudo env ARCHFLAGS="-arch x86_64" gem install pg</code></p>
<h2>Configuring your Rails Application</h2>
<p>Inside your Ruby on Rails application, open up config/database.yml and change your development adapter to be similar to the following:</p>
<p><code>development:<br />
  adapter: postgresql<br />
  database: defaultdb<br />
  username: defaultdb<br />
</code></p>
<p>You can change <code>defaultdb</code> to the name you need for your application.</p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

