<?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>Tracy Phillips &#187; postgresql</title>
	<atom:link href="http://tracyphillips.com/tag/postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://tracyphillips.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Oct 2009 14:12:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Install and Setup PostgreSQL on FreeBSD</title>
		<link>http://tracyphillips.com/2005/12/01/install-and-setup-postgresql-on-freebsd-2/</link>
		<comments>http://tracyphillips.com/2005/12/01/install-and-setup-postgresql-on-freebsd-2/#comments</comments>
		<pubDate>Thu, 01 Dec 2005 19:51:59 +0000</pubDate>
		<dc:creator>tracphil</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://www.tracyphillips.com/?p=8</guid>
		<description><![CDATA[Installing PostgreSQL on FreeBSD is the topic of the day. If you haven't been following this little series, make sure you have portupgrade installed. What we want to accomplish today are the following. Install PostgreSQL Initialize PostgreSQL with initdb Setup the postgres db with UNICODE Only allow logins with MD5 authentication Setup PostgreSQL to start [...]]]></description>
			<content:encoded><![CDATA[<p>Installing <a href="http://www.postgresql.org/">PostgreSQL</a> on <a href="http://www.freebsd.org/">FreeBSD</a> is the topic of the day. If you haven't been following <a href="http://www.tracyphillips.com/2005/11/new-server-setup/">this little series</a>, make sure you have portupgrade installed.</p>
<p>What we want to accomplish today are the following.</p>
<ul>
<li>Install PostgreSQL</li>
<li>Initialize PostgreSQL with initdb</li>
<li>Setup the postgres db with UNICODE</li>
<li>Only allow logins with MD5 authentication</li>
<li>Setup PostgreSQL to start when the server is started.</li>
<li>Setup a db user that will connect remotely via pgAdmin III</li>
<li>Setup PostgreSQL so that we can connect remotely from our workstation.</li>
<li>Setup PostgreSQL to Autovacuum.</li>
</ul>
<p>I would like to thank AndrewSN from <code>#postgresql</code> on <code>irc.freenode.com</code>. His knowledge of PostgreSQL is what made possible the tiny details in configuring a PostgreSQL server correctly.</p>
<p>Digest all of that and hurry up so you will not be late for the party.</p>
<p>This is not going to take that long at all to setup if you are familiar with <a href="http://www.vim.org/">vim</a> and how to search for things in files.</p>
<p>First lets just install Postgresql. I chose postgresql 8.1 and just used the default configure settings that came up.</p>
<pre>[server][root][~]# portinstall postgresql-server</pre>
<p>Don't you just love <a href="http://www.freebsd.org/ports/index.html">FreeBSD Ports</a> and how much easier it makes life? Ports are much better than RPM Hell any day of the week, although YUM makes things tolerable.</p>
<p>Next lets use initdb to initialize the postgresq db and get things setup the way we want them. This one line will take care of our second, third and fourth items on the list.
<pre>[server][root][~]# su -l pgsql -c "initdb -D /usr/local/pgsql/data -E UNICODE -A 'ident sameuser'"</pre>
<p>Now what we need to do is setup <code>/etc/rc.conf</code> so that PostgreSQL gets started when the server is started. Issue the following at the command line and you will be all set:
<pre>[server][root][~]# echo 'postgresql_enable="YES"' >> /etc/rc.conf</pre>
<p>Start PostgreSQL so that we can create a new role.</p>
<pre>[server][root][~]# /usr/local/etc/rc.d/010.pgsql.sh start</pre>
<p>Now let's create the new user/role that we will use to login remotely with. The -P option of createuser prompts you for a password that will authenticate the new user, -U is the username you're connecting as (NOT the user you're creating), and then monty is the name of the new user. My comments are in ( ).</p>
<pre>[server][root][~]# su pgsql -c 'createuser -P monty'</pre>
<pre>Enter password for new role: montypass (monty's password)
Enter it again: montypass (confirm monty's password)
Shall the new role be a superuser? (y/n) y (let monty be a superuser)
CREATE ROLE</pre>
<p>Now we can get PostgrSQL setup to allow us to connect from our IP address. To do that we need to edit two files, <code>/usr/local/pgsql/data/postgresql.conf</code> and <code>/usr/local/pgsql/data/pg_hba.conf</code>.</p>
<pre>[server][root][~]# vi /usr/local/pgsql/data/postgresql.conf</pre>
<p>Search for <code>listen_addresses</code> and change it to look like:
<pre>listen_addresses = '*'</pre>
<p>Search for <code>password_encryption</code> and uncomment it (delete the #)</p>
<pre>password_encryption = on</pre>
<p>Search for <code>port</code> and uncomment it and make sure the port number is 5432</p>
<pre>port = 5432</pre>
<p>To enable <code>pg_autovacuum</code> search for the following items and make sure they are uncommented and set to <code>on</code></p>
<pre>stats_start_collector = on
stats_row_level = on
autovacuum = on</pre>
<p>Now lets fire up vi with the second file we need to edit</p>
<pre>[server][root][~]# vi /usr/local/pgsql/data/pg_hba.conf</pre>
<p>Search for <code># "local" is for Unix domain socket</code> (should be about line 66) and make the local section identical to what we have here. Beneath host all 127.0.0.1/32 md5 add your IP address or netblock. I am doing this on a local network so I just allow a connection from any of my internal IP Addresses.</p>
<pre># TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
# "local" is for Unix domain socket connections only
local   all         pgsql                             ident sameuser
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
host    all         all         192.168.1.0/24        md5
#IPv6 local connections:
host    all         all         ::1/128               md5</pre>
<p>Open up (or create) <code>/etc/periodic.conf</code> to automatically perform daily backups (and tell it where and how to back them up) and turn off daily vacuum since we turned on autovacuum in the <code>postgresql.conf</code> file.</p>
<pre>daily_pgsql_vacuum_enable="NO"
daily_pgsql_backup_enable="YES"
daily_pgsql_pgdump_args="-F c"
daily_pgsql_backupdir="~pgsql/backups"
daily_pgsql_savedays="7"</pre>
<p>Now start/restart PostgreSQL</p>
<pre>[server][root][~]# /usr/local/etc/rc.d/010.pgsql.sh restart</pre>
<p>AndrewSN from <code>#postgresql</code> on Freenode said that there is a bug in the FreeBSD port:</p>
<blockquote><p>You can fix the bug by copying <code>install-sh</code> and <code>mkinstalldirs</code> from the config dir of the distribution into <code>/usr/local/lib/postgresql/pgxs/config</code> if they don't already exist there.</p>
<p>If you don't do that, then you can't build extensions that use pgxs.</p>
</blockquote>
<p>Ok, that is all there is to getting PostgreSQL installed and configured for a remote connection. It wasn't all that painful was it? I sure hope not :)</p>
<p>Next we will go about installing and setting up Lighttpd.</p>
<p><u><strong>Rails Server Setup:</strong></u></p>
<p>Part 1: <a href="http://www.tracyphillips.com/2005/11/new-server-setup/">New Server Setup</a><br />
Part 2: <a href="http://www.tracyphillips.com/2005/11/setup-freebsd-6x-for-ruby-on-rails.php">Setup FreeBSD 6.x</a><br />
Part 3: <a href="http://www.tracyphillips.com/2005/11/freebsd-usability/">FreeBSD Usability</a><br />
Part 4: <a href="http://www.tracyphillips.com/2005/11/setup-freebsd-to-use-blowfish/">Setup FreeBSD To Use Blowfish</a><br />
Part 5: Install and Setup PostgreSQL<br />
Part 6: <a href="http://www.tracyphillips.com/2005/12/install-lighttpd-on-freebsd/">Install Lighttpd on FreeBSD</a><br />
Part 7: <a href="http://www.tracyphillips.com/2005/12/install-mysql-5x-on-freebsd/">Install MySQL 5.x on FreeBSD</a><br />
Part 8: <a href="http://www.tracyphillips.com/2005/12/ruby-on-rails-setup-with-freebsd/">Install Ruby On Rails with FreeBSD</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tracyphillips.com/2005/12/01/install-and-setup-postgresql-on-freebsd-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Server Setup</title>
		<link>http://tracyphillips.com/2005/11/28/new-server-setup-2/</link>
		<comments>http://tracyphillips.com/2005/11/28/new-server-setup-2/#comments</comments>
		<pubDate>Mon, 28 Nov 2005 23:41:32 +0000</pubDate>
		<dc:creator>tracphil</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://www.tracyphillips.com/?p=22</guid>
		<description><![CDATA[I am going through the process of switching from a Linux server (CentOS to be exact) running DirectAdmin as the control panel to a FreeBSD server with no control panel for management. Since I do not have to build within the constraints of some other company's control panel, I thought I would install the best [...]]]></description>
			<content:encoded><![CDATA[<p>I am going through the process of switching from a Linux server (<a href="http://www.centos.org/">CentOS</a> to be exact) running <a href="http://www.directadmin.com">DirectAdmin</a> as the control panel to a <a href="http://www.freebsd.org/">FreeBSD</a> server with no control panel for management. Since I do not have to build within the constraints of some other company's control panel, I thought I would install the best of breed servers and applications.</p>
<p>The main components that I require to be installed are:</p.</p>
<p><a href="http://www.postgresql.org/">PostgreSQL</a><br />
<a href="http://www.lighttpd.net/">Lighttpd</a><br />
<a href="http://www.rubyonrails.org">Ruby On Rails</a><br />
<a href="http://subversion.tigris.org/">Subversion</a><br />
<a href="http://www.postfix.org/">Postfix</a><br />
<a href="http://www.dovecot.org/">Dovecot</a><br />
<a href="http://www.nuclearelephant.com/">Dspam</a></p>
<p>I will most likely do some more tweaking but at the moment that is the standard I wish to build against. I know for a fact that I will do some more "tweaking" such as setting up DNS RBLS, <a href="http://www.openspf.org/">SPF</a>, and maybe even Yahoo <a href="http://domainkeys.sourceforge.net/">Domain Keys</a> along with some good old postfix filtering for spam (can you tell I hate spam).<br />
The fist thing that I will get to (hopefully in the next post) will be setting up FreeBSD 6 and getting it ready to install applications onto.</p>
<p><u><strong>Rails Server Setup:</strong></u></p>
<p>Part 1: New Server Setup<br />
Part 2: <a href="http://www.tracyphillips.com/2005/11/setup-freebsd-6x-for-ruby-on-rails/">Setup FreeBSD 6.x</a><br />
Part 3: <a href="http://www.tracyphillips.com/2005/11/freebsd-usability/">FreeBSD Usability</a><br />
Part 4: <a href="http://www.tracyphillips.com/2005/11/setup-freebsd-to-use-blowfish.php">Setup FreeBSD To Use Blowfish</a><br />
Part 5: <a href="http://www.tracyphillips.com/2005/12/install-and-setup-postgresql-on-freebsd/">Install and Setup PostgreSQL</a><br />
Part 6: <a href="http://www.tracyphillips.com/2005/12/install-lighttpd-on-freebsd/">Install Lighttpd on FreeBSD</a><br />
Part 7: <a href="http://www.tracyphillips.com/2005/12/install-mysql-5x-on-freebsd/">Install MySQL 5.x on FreeBSD</a><br />
Part 8: <a href="http://www.tracyphillips.com/2005/12/ruby-on-rails-setup-with-freebsd.php">Install Ruby On Rails with FreeBSD</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tracyphillips.com/2005/11/28/new-server-setup-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
