<?xml version='1.0' encoding='utf-8' ?>
<!--  If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/  -->
<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Ted&apos;s Shed</title>
  <link>http://trak3r.livejournal.com/</link>
  <description>Ted&apos;s Shed - LiveJournal.com</description>
  <lastBuildDate>Thu, 09 Jun 2005 22:08:30 GMT</lastBuildDate>
  <generator>LiveJournal / LiveJournal.com</generator>
  <lj:journal>trak3r</lj:journal>
  <lj:journalid>1109114</lj:journalid>
  <lj:journaltype>personal</lj:journaltype>
  <atom10:link rel='hub' href='http://pubsubhubbub.appspot.com/' />
  <image>
    <url>http://l-userpic.livejournal.com/20877942/1109114</url>
    <title>Ted&apos;s Shed</title>
    <link>http://trak3r.livejournal.com/</link>
    <width>84</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/55662.html</guid>
  <pubDate>Thu, 09 Jun 2005 22:08:30 GMT</pubDate>
  <title>PHP &amp; PostgreSQL Woes, Part Four</title>
  <link>http://trak3r.livejournal.com/55662.html</link>
  <description>OK, time for the pain!&lt;br /&gt;&lt;br /&gt;First up, let me ensure that I&apos;ve restored all the configuration files to their original state...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ su
Password: 
[root@basement tdavis]# cd /var/lib/pgsql/data/
[root@basement data]# cp pg_hba.conf.original pg_hba.conf
cp: overwrite `pg_hba.conf&apos;? y
[root@basement data]# cp pg_ident.conf.original pg_ident.conf
cp: overwrite `pg_ident.conf&apos;? y
&lt;/pre&gt;&lt;br /&gt;Check.&lt;br /&gt;&lt;br /&gt;And a little restart...&lt;br /&gt;&lt;pre&gt;
[root@basement data]# /sbin/service postgresql restart
Stopping postgresql service: [  OK  ]
Starting postgresql service: [  OK  ]
&lt;/pre&gt;&lt;br /&gt;Check.&lt;br /&gt;&lt;br /&gt;A little review of my test script...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement 050609]$ cat insert.php 
&amp;lt;?php
ini_set(&apos;display_errors&apos;,true);
$dbconn=pg_connect(&quot;dbname=basement user=tdavis password=pokesmot&quot;);
$rset=pg_query($dbconn,&quot;select * from users&quot;);
$array=pg_fetch_array($rset);
echo $array[&quot;username&quot;];
echo &quot;\n&quot;;
pg_close($dbconn);
?&amp;gt;
&lt;/pre&gt;&lt;br /&gt;... and make sure it runs (it should print &quot;tdavis&quot;)...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement 050609]$ php insert.php 
Content-type: text/html
X-Powered-By: PHP/4.3.11

tdavis
&lt;/pre&gt;&lt;br /&gt;Bingo!  &lt;br /&gt;&lt;br /&gt;Now let&apos;s load it up from the web...&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket &quot;/tmp/.s.PGSQL.5432&quot;? in /home/tdavis/public_html/050609/insert.php on line 3&lt;br /&gt;&lt;br /&gt;Warning: pg_query(): supplied argument is not a valid PostgreSQL link resource in /home/tdavis/public_html/050609/insert.php on line 4&lt;br /&gt;&lt;br /&gt;Warning: pg_fetch_array(): supplied argument is not a valid PostgreSQL result resource in /home/tdavis/public_html/050609/insert.php on line 5&lt;br /&gt;&lt;br /&gt;Warning: pg_close(): supplied argument is not a valid PostgreSQL link resource in /home/tdavis/public_html/050609/insert.php on line 8&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Curses!&lt;br /&gt;&lt;br /&gt;Considering that it works from the command line but not from the web, I&apos;m pretty confident that this is an &apos;ident&apos; issue with PostgreSQL authentication.  Essentially, the tdavis Unix account can connect to the tdavis database account, but the apache Unix account may not.&lt;br /&gt;&lt;br /&gt;First I&apos;ll try the suggestion Larry Klug posted: changing &apos;ident&apos; to &apos;trust&apos;, which essentially means &quot;let anybody log in&quot;...&lt;br /&gt;&lt;pre&gt;
[root@basement data]# diff pg_hba.conf pg_hba.conf.original 
66c66
&amp;lt; local  all    all             trust
---
&amp;gt; local  all    all             ident   sameuser
&lt;/pre&gt;&lt;br /&gt;... and another restart...&lt;br /&gt;&lt;pre&gt;
[root@basement data]# /sbin/service postgresql restart
Stopping postgresql service: [  OK  ]
Starting postgresql service: [  OK  ]
&lt;/pre&gt;&lt;br /&gt;... and a hit from the browser...&lt;br /&gt;&lt;br /&gt;BAM!  Same error. &lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket &quot;/tmp/.s.PGSQL.5432&quot;? in /home/tdavis/public_html/050609/insert.php on line 3&lt;br /&gt;&lt;br /&gt;Warning: pg_query(): supplied argument is not a valid PostgreSQL link resource in /home/tdavis/public_html/050609/insert.php on line 4&lt;br /&gt;&lt;br /&gt;Warning: pg_fetch_array(): supplied argument is not a valid PostgreSQL result resource in /home/tdavis/public_html/050609/insert.php on line 5&lt;br /&gt;&lt;br /&gt;Warning: pg_close(): supplied argument is not a valid PostgreSQL link resource in /home/tdavis/public_html/050609/insert.php on line 8&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Round and round she goes.  Where she stops, nobody knows!</description>
  <comments>http://trak3r.livejournal.com/55662.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/55366.html</guid>
  <pubDate>Wed, 08 Jun 2005 23:33:44 GMT</pubDate>
  <title>I&apos;ll work on it tomorrow, I swear!</title>
  <link>http://trak3r.livejournal.com/55366.html</link>
  <description>I spent last night with my daughter, and tonight I&apos;m headed over to my girlfriend&apos;s to watch a movie.  Tomorrow night I&apos;m going to work on Project Basement.  Really.  I swear.  Hmm... but I do have two new Netflix discs on my coffee table.  Must resist!  Must produce!  We&apos;ll see :-)</description>
  <comments>http://trak3r.livejournal.com/55366.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/55080.html</guid>
  <pubDate>Tue, 07 Jun 2005 12:47:19 GMT</pubDate>
  <title>Info on 3.9M Citigroup customers lost</title>
  <link>http://trak3r.livejournal.com/55080.html</link>
  <description>(according to CNNMoney) and MC has only been working there a week!  That&apos;s got to be a new record ;-)</description>
  <comments>http://trak3r.livejournal.com/55080.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/54996.html</guid>
  <pubDate>Tue, 07 Jun 2005 01:54:37 GMT</pubDate>
  <title>PHP &amp; PostgreSQL Woes, Part Two and One-Half</title>
  <link>http://trak3r.livejournal.com/54996.html</link>
  <description>I wasted another hour banging my head against getting PHP to talk to PostgreSQL with no luck.  At one point I decided to shut down the database just to see if PHP would give me a useful error message.  The error changed slightly to:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket &quot;/tmp/.s.PGSQL.5432&quot;?&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;And here&apos;s the kicker: after I started the database back up again, PHP &lt;em&gt;continued&lt;/em&gt; to say it could not connect to the server.  So I restarted Apache.  Nope!  How about if I reboot the entire machine?  Sorry.  I have &lt;em&gt;really&lt;/em&gt; screwed something up now... yet all of the configuration files have been restored to their original state (I always make backups).</description>
  <comments>http://trak3r.livejournal.com/54996.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/54599.html</guid>
  <pubDate>Mon, 06 Jun 2005 23:55:08 GMT</pubDate>
  <title>PHP &amp; PostgreSQL Woes, Part Two</title>
  <link>http://trak3r.livejournal.com/54599.html</link>
  <description>Another fruitless day trying to get PHP talking to PostgreSQL.&lt;br /&gt;&lt;br /&gt;It seems there&apos;s two approaches to this.&lt;br /&gt;&lt;br /&gt;The first is to tell PostgreSQL to allow the Unix account running PHP (Apache) to connect to the database.&lt;br /&gt;&lt;br /&gt;This is, according to my Googles, configured in a file called pg_hba.conf&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ sudo find / -name pg_hba.conf &amp;gt;find 2&amp;gt;errors; cat find
/var/lib/pgsql/data/pg_hba.conf
&lt;/pre&gt;&lt;br /&gt;This file contains a single line:&lt;br /&gt;&lt;pre&gt;
local  all    all             ident   sameuser
&lt;/pre&gt;&lt;br /&gt;And the documentation explains that this tells PosgreSQL to allow any local users to connect to any database and assume their Unix username is the same as their PostgreSQL username:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;ident&lt;br /&gt;&lt;br /&gt;Obtain the operating system user name of the client (for TCP/IP connections by contacting the ident server on the client, for local connections by getting it from the operating system) and check if the user is allowed to connect as the requested database user by consulting the map specified after the ident key word. See Section 19.2.4 for details. &lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;So what I need to do, apparently, is to create a new mapping that says Unix account &apos;apache&apos; is allowed to log in as PostgreSQL user &apos;tdavis&apos;...&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;19.2.4.3. Ident Maps&lt;br /&gt;&lt;br /&gt;When using ident-based authentication, after having determined the name of the operating system user that initiated the connection, PostgreSQL checks whether that user is allowed to connect as the database user he is requesting to connect as. This is controlled by the ident map argument that follows the ident key word in the pg_hba.conf file. There is a predefined ident map sameuser, which allows any operating system user to connect as the database user of the same name (if the latter exists). Other maps must be created manually. &lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;So I added the new line to pg_hba.conf and added the user mapping to pg_ident.conf and restarted PostgreSQL... no luck.  Same error.&lt;br /&gt;&lt;br /&gt;The second option is to create a new user for the &apos;apache&apos; account to use.&lt;br /&gt;&lt;pre&gt;
[root@basement data]# su postgres
bash-3.00$ createuser
Enter name of user to add: apache
Shall the new user be allowed to create databases? (y/n) n
Shall the new user be allowed to create more new users? (y/n) n
CREATE USER
&lt;/pre&gt;&lt;br /&gt;And give it access to the basement database:&lt;br /&gt;&lt;pre&gt;
postgres=# grant all on database basement to apache;
GRANT
&lt;/pre&gt;&lt;br /&gt;Now this sucks.  I don&apos;t want this account to have complete access to the database.  I want this account to be able to select, insert, update, and delete, but not create new tables or drop existing tables, etc.  But in order to achieve that level of access, I would have to grant it &lt;em&gt;per table&lt;/em&gt;!  OMG!&lt;br /&gt;&lt;br /&gt;Sanity check:&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ psql basement
Welcome to psql 7.4.8, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

basement=&amp;gt; \du
              List of database users
 User name | User ID |         Attributes         
-----------+---------+----------------------------
 apache    |     101 | 
 postgres  |       1 | superuser, create database
 tdavis    |     100 | 
(3 rows)
&lt;/pre&gt;&lt;br /&gt;Restart PostgreSQL... nope.  Still no access.  Sucks.  Sigh.&lt;br /&gt;&lt;br /&gt;P. S.  I&apos;m an old emacs fanatic, but for today&apos;s session I used vi just to see what all the fuss was about.  I&apos;ll use it again in future sessions before I make any judgements.  So far I&apos;m neither impressed nor disappointed.</description>
  <comments>http://trak3r.livejournal.com/54599.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>6</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/54428.html</guid>
  <pubDate>Sun, 05 Jun 2005 22:21:11 GMT</pubDate>
  <title>PHP &amp; PostgreSQL Woes, Part One</title>
  <link>http://trak3r.livejournal.com/54428.html</link>
  <description>I&apos;ll spare you the twelve-page narration of my trials and tribulations and tell you simply that I am working on Project Basement this afternoon and I&apos;ve not yet figured out how to connect to the PostgreSQL database from PHP.&lt;br /&gt;&lt;br /&gt;Here&apos;s my code:&lt;br /&gt;&lt;pre&gt;
&amp;lt;?php
ini_set(&apos;display_errors&apos;,true);
$dbconn=pg_connect(&quot;dbname=basement&quot;);
pg_insert($dbconn,&apos;users&apos;,$_POST);
pg_close($dbconn);
?&amp;gt;
&lt;/pre&gt;&lt;br /&gt;And here&apos;s my error message:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket &quot;/tmp/.s.PGSQL.5432&quot;? in /home/tdavis/public_html/censored_for_my_protection.php on line 3&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;I&apos;m Googling for a solution at the moment.</description>
  <comments>http://trak3r.livejournal.com/54428.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/54137.html</guid>
  <pubDate>Thu, 02 Jun 2005 15:45:54 GMT</pubDate>
  <title>In case any of my WoW buddies read this...</title>
  <link>http://trak3r.livejournal.com/54137.html</link>
  <description>&lt;a href=&quot;http://www.thinkgeek.com/pennyarcade/swag/76e8/&quot;&gt;http://www.thinkgeek.com/pennyarcade/swag/76e8/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I&apos;ll send you 400G in game for one of these ;-)</description>
  <comments>http://trak3r.livejournal.com/54137.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/53864.html</guid>
  <pubDate>Thu, 02 Jun 2005 15:10:46 GMT</pubDate>
  <title>Another Lull</title>
  <link>http://trak3r.livejournal.com/53864.html</link>
  <description>Fear not, faithful readers.  Project Basement is not yet dead, just suffering another lull as work saps me of all my energy and traveling this weekend will prohibit any productivity.  I plan to throw together some user account creation and log-in scripts as my next feet-whetting project, then I&apos;ll set up some revision control system to preserve my work (and my sanity).</description>
  <comments>http://trak3r.livejournal.com/53864.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/53593.html</guid>
  <pubDate>Wed, 01 Jun 2005 15:07:24 GMT</pubDate>
  <title>Showering makes you fat!</title>
  <link>http://trak3r.livejournal.com/53593.html</link>
  <description>I have a digital scale right next to my shower.  This morning when I dragged my ass out of bed I stepped on.  It read 138.5.  I stepped off, waited for it to reset, then stepped on again.  I always weigh myself twice to ensure the first reading wasn&apos;t a fluke.  138.5 again.  OK.  That&apos;s cool.  I took my shower.  After I dried off and stepped out, I thought, why not weight myself again just for laughs.  140.0.  Then again.  140.0 both times.  I gained 1.5 pounds in the shower.  My only hypothesis is that my body absorbed that much water; but that seems like an awful lot.  Wild.</description>
  <comments>http://trak3r.livejournal.com/53593.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>5</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/53302.html</guid>
  <pubDate>Wed, 01 Jun 2005 02:43:21 GMT</pubDate>
  <title>Oh yeah, I ran a 5K</title>
  <link>http://trak3r.livejournal.com/53302.html</link>
  <description>On Monday I ran my first 5K of 2005.  It was the one-year anniversary of my first 5K ever.  It was the first 5K I&apos;d run since the Firefighter 5K in September of last year.  During the winter months I stopped running and put on some extra poundage.  I can&apos;t stand running in cold weather; breathing in the cold air makes me feel like crap.  A couple months ago I started running again, but nowhere near the rigorous schedule of last year.  I expected to do mediocre in the race on Monday, but surprisingly I ran my best time ever (just over 29 minutes).  I guess I just might have to run a few more races this summer.</description>
  <comments>http://trak3r.livejournal.com/53302.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/53012.html</guid>
  <pubDate>Mon, 30 May 2005 01:10:46 GMT</pubDate>
  <title>PHP Woes, Part One</title>
  <link>http://trak3r.livejournal.com/53012.html</link>
  <description>I whipped up the obligatory &quot;hello world&quot; PHP script and... it worked!  I didn&apos;t have to futz with anything!  I&apos;m speechless.&lt;br /&gt;&lt;br /&gt;My first order of business was to figure out how includes worked.  You know, code re-use and all that jazz.  I want to be able to write a piece of code once and then import it into all the pages that need it.&lt;br /&gt;&lt;br /&gt;Not surprisingly, the keyword for including another source file is &quot;include&quot;.  Surprisingly, there&apos;s &lt;em&gt;four&lt;/em&gt; variations of it.  WTF!?  Get this...&lt;br /&gt;&lt;br /&gt;include()&lt;br /&gt;&lt;br /&gt;- Imports and executes another source file.&lt;br /&gt;&lt;br /&gt;include_once()&lt;br /&gt;&lt;br /&gt;- Imports and executes another source file only one time in case it&apos;s imported multiple times.  Oh ho ho.  This just stinks of a bug that was promoted to a feature.  Importing external sources multiple times is going to cause namespace collisions and wreak all sorts of havoc.  This should have been the default implementation IMHO.  Backwards compatibility is a bitch; you have to keep big bugs and crappy APIs around just for the sake of not pissing off your user base.  Yeah Java, I&apos;m looking at you too.&lt;br /&gt;&lt;br /&gt;require()&lt;br /&gt;&lt;br /&gt;- This does almost the exact same thing as include, but it throws a &quot;fatal exception&quot; if there&apos;s a problem with the external file, as opposed to include&apos;s &quot;warning&quot;.  That&apos;s a nice hack.&lt;br /&gt;&lt;br /&gt;require_once()&lt;br /&gt;&lt;br /&gt;- You should be able to figure out what this one does.&lt;br /&gt;&lt;br /&gt;I think I&apos;m going to play it safe and use require_once exclusively (if I can).  It seems to be the most logical implementation, and I&apos;m betting it was the last version of this debacle added to the language.  I can see why you might want to include and execute and external file multiple times, but those are extreme cases and there are certainly other (cleaner) ways to accomplish the same thing.  And I&apos;m a big proponent of code breaking rather than limping along.  If something isn&apos;t right, I want the flow to stop immediately before more potential damage can be done.&lt;br /&gt;&lt;br /&gt;So I added a couple includes to my test script.  I intentionally included a non-existent file.  No fatal error reported.  WTF?  It seems PHP by default doesn&apos;t dump error diagnosis to the web page for security reasons.  I can agree with that.  But where the frick are the errors logged?  I&apos;ve not yet figured that out.  And even though the error isn&apos;t detailed on the page, I&apos;d at least like to see notification that &lt;em&gt;something&lt;/em&gt; is amiss.  I&apos;m researching those API calls now...&lt;br /&gt;&lt;br /&gt;The first candidate seemed to be display_errors, which is documented to &quot;determine whether errors should be printed to the screen as part of the output&quot;, but if you keep reading, there&apos;s a catch: &quot;it won&apos;t have any affect if the script has fatal errors.&quot;  Remember that &quot;require&quot; throws a fatal error.  Oops.  No help there.&lt;br /&gt;&lt;br /&gt;The next candidate seems to be log_errors, which is documented to &quot;Tell whether script error messages should be logged to the server&apos;s error log or error_log.&quot;  And if you follow up on error_log you discover that it is the &quot;name of the file where script errors should be logged. The file should be writable by the web server&apos;s user.&quot;  Alright, I&apos;ll give that a whirl.&lt;br /&gt;&lt;pre&gt;
&amp;lt;?php
error_log(&apos;/home/tdavis/public_html/error.log&apos;);
log_errors(true);
require_once &apos;missing.php&apos;;
?&amp;gt;
&lt;/pre&gt;&lt;br /&gt;Create the file...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement public_html]$ echo &amp;gt; /home/tdavis/public_html/error.log
[tdavis@basement public_html]$ chmod 666 error.log 
[tdavis@basement public_html]$ ls --scontext | grep error
user_u:object_r:httpd_sys_content_t error.log
&lt;/pre&gt;&lt;br /&gt;Hit the page and check the log...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement public_html]$ cat error.log 
&lt;/pre&gt;&lt;br /&gt;Nothing.  Empty.  Nada.  Are you starting to grasp the beauty of this?  I can&apos;t figure out how to get error logging working... and there&apos;s no way to debug it because none of the errors are being logged!  I just might beat myself senseless... oh, too late.&lt;br /&gt;&lt;br /&gt;Fortunately for me, I have root access, so I can peek at the Apache logs.&lt;br /&gt;&lt;pre&gt;
[client 24.233.173.197] /home/tdavis/public_html/error.log
[client 24.233.173.197] PHP Fatal error:  Call to undefined function:  
    log_errors() in /home/tdavis/public_html/test.php on line 3
&lt;/pre&gt;&lt;br /&gt;Er... it seems that my call to error_log simply printed the string to the main log rather than setting the file path... wtf?  Also, log_errors is undefined?  Grr.&lt;br /&gt;&lt;br /&gt;Oh, error_log is not a function name, well it is, but it&apos;s &lt;em&gt;also&lt;/em&gt; a property name, and the latter is what I want.  Now how do I set it?  I haven&apos;t yet figured that out.  Supposedly I can set it at run time using ini_set(), but as already stated above, in the case of a &quot;fatal&quot; error, as require_once throws, runtime settings are a moot point.  Sigh.&lt;br /&gt;&lt;br /&gt;But wait a second.  How often is the documentation correct, much less consistent?  Hell, I&apos;m going to try it...&lt;br /&gt;&lt;pre&gt;
&amp;lt;?php
ini_set(&apos;display_errors&apos;,true);
require_once &apos;missing.php&apos;;
?&amp;gt;
&lt;/pre&gt;&lt;br /&gt;Bam!&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Warning: main(missing.php): failed to open stream: No such file or directory in /home/tdavis/public_html/test.php on line 3&lt;br /&gt;&lt;br /&gt;Fatal error: main(): Failed opening required &apos;missing.php&apos; (include_path=&apos;.:/usr/share/pear&apos;) in /home/tdavis/public_html/test.php on line 3&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Bingo!</description>
  <comments>http://trak3r.livejournal.com/53012.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/52842.html</guid>
  <pubDate>Sun, 29 May 2005 04:49:54 GMT</pubDate>
  <title>The day the Klug saved Christmas</title>
  <link>http://trak3r.livejournal.com/52842.html</link>
  <description>It&apos;s 12:30AM, Saturyday night (Sunday morning).  I made the mistake of checking my e-mail right before bed.  Lo and behold I had a comment in my blog from a very old friend and colleague, Larry Klug.&lt;br /&gt;&lt;br /&gt;Larry and I worked together at the beginning of the dot com explosion.  I remember Larry as a young Visual Basic coder who pined about his days of airbrushing t-shirts and serving customers the &quot;onion of the day&quot;... and of course the management of the official Gram Parson&apos;s web site and fan club.&lt;br /&gt;&lt;br /&gt;Many years ago, when our dot com baby went bust, we went our separate ways.  But a year or so ago I rediscovered Larry through his blog.  I discovered, from his writings, that he&apos;d become quite the accomplished tech guru, jetsetting about and dabbling with, hell &lt;em&gt;mastering&lt;/em&gt; wonderful niche technologies that I can only dream about having (making?) the time to explore.  His rants about synching his iPod from Linux left me dumbfounded.  He was &quot;in the shit&quot; (as you might hear from a cliche Vietnam war movie) in regards to coding.  He was getting down and dirty with device drivers and code on the bleeding edge.  I silently envied him from afar.  &lt;br /&gt;&lt;br /&gt;And on this fateful night, my dear friends, Larry enlightened me.  He pulled my head out of the sand and showed me the path that I had lost.  He earned his sainthood this evening by exposing the solution to my Apache problem that I now realize I was &lt;em&gt;nowhere&lt;/em&gt; close to resolving on my own and probably would not have for a very long painful time to come...&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Subject: Sealed for your protection&lt;br /&gt;&lt;br /&gt;One word: SELinux&lt;br /&gt;&lt;br /&gt;Fedora Core 3 ships with an SELinux kernel. SELinux (Security Enhanced Linux) is essentially a way to add an additional layer of file permissions over and above the normal users/groups permissions. In short, chmod will not help you. You should instead use the command chcon to change the security context of the directory you want to use. Apache should really add this to their FAQ. Even though RedHat is really to blame, the Apache FAQ is the first place someone might look for a solution. Unfortunately, this one is too new to be easy to find in the usual places. You can disable SELinux completely, or try something like: &quot;chcon -t httpd_sys_content_t /home/tdavis/basement&quot;.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Wow.  That sounds like good stuff.  A little googling turned up this gem which corroborates Larry&apos;s explanation:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.networkclue.com/os/Linux/commands/chcon.php&quot;&gt;http://www.networkclue.com/os/Linux/commands/chcon.php&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So let&apos;s play with this...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ ls --scontext
user_u:object_r:user_home_t      Desktop
user_u:object_r:user_home_t      errors
user_u:object_r:user_home_t      find
user_u:object_r:user_home_t      public_html
&lt;/pre&gt;&lt;br /&gt;Interesting...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ ls --scontext /var/www
system_u:object_r:httpd_sys_script_exec_t cgi-bin
system_u:object_r:httpd_sys_content_t error
system_u:object_r:httpd_sys_content_t html
system_u:object_r:httpd_sys_content_t icons
system_u:object_r:httpd_sys_content_t manual
system_u:object_r:httpd_sys_content_t usage
&lt;/pre&gt;&lt;br /&gt;Yes indeed it seems httpd_sys_content_t is the magic value.  Let&apos;s give it a whirl...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ chcon --type httpd_sys_content_t public_html
&lt;/pre&gt;&lt;br /&gt;Nope, but it gave me a different error message, which is promising.  Let&apos;s try a little deeper.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ cd public_html/
[tdavis@basement public_html]$ chcon --type httpd_sys_content_t index.html 
&lt;/pre&gt;&lt;br /&gt;HALLELUJAH!!!&lt;br /&gt;&lt;br /&gt;Thanks Larry!  I owe you one.  I owe you a big one!</description>
  <comments>http://trak3r.livejournal.com/52842.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/52670.html</guid>
  <pubDate>Sun, 29 May 2005 04:16:28 GMT</pubDate>
  <title>Firefly</title>
  <link>http://trak3r.livejournal.com/52670.html</link>
  <description>After reading all the &quot;gull ram&quot; hype about this TV series on Slashdot, and the news of the upcoming feature film Serenity (the name of the space ship, and the pilot episode), I rented the first (and only) season on DVD to see what it&apos;s all about.  It started out good and got better.  It&apos;s not a &quot;great&quot; show in my book, but it breaks a lot of cliches for it&apos;s genre.  It&apos;s the anti-Roddenberryian space adventure.  The captain kills with little remorse.  You won&apos;t see any Wrath of Kahn spin-offs from this show -- you cross the captain and he leaves you stone cold dead.  His crew doesn&apos;t follow him blindly like mindless puppies -- hell one of them even tries to turn the others in for their bounties.  Romances aren&apos;t wrapped up in single episodes, nor are they clean and pretty.  People get shot; both good and bad.  People die; both good and bad.  The acting is solid.  The writing is solid.  It&apos;s a nice piece of entertainment and I can certainly see why it had such a passionate following.  There&apos;s no grand sub-plot like Babylon 5 or the X-Files.  It&apos;s pretty episodic with most continuity simply preserved for humor value -- the crew doesn&apos;t let each other forget their embarrassing faux pas from past adventures.  I don&apos;t know anything about the upcoming movie, but I hope it wraps up some of the dangling threads from the series... and in some way I hope it leaves a few of those threads still dangling.  For example, I want to know what&apos;s wrong with the lobotomized chick, but I don&apos;t care to see the captain and the on-board whore confess their hidden love for each other.  I guess it all depends on how much control the originator (Josh Whedon) is able to preserve when the big movie studio execs decide to step in and candy coat everything.  If I had a nickel for every DVD I&apos;ve rented that has the bonus track with the &quot;original ending the studio made us rewrite&quot; that made me gasp in awe at how much better the film would have been if they didn&apos;t all sail off into the sunset at the end and live happily every after.</description>
  <comments>http://trak3r.livejournal.com/52670.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/52381.html</guid>
  <pubDate>Sun, 29 May 2005 00:36:11 GMT</pubDate>
  <title>Apache Woes, Part Four</title>
  <link>http://trak3r.livejournal.com/52381.html</link>
  <description>Because I&apos;m a glutton for punishment, I press on...&lt;br /&gt;&lt;br /&gt;Maybe the problem is specific to the special index.html file name.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ cd public_html/
[tdavis@basement public_html]$ echo &quot;hello world&quot; &amp;gt; snafu.html
[tdavis@basement public_html]$ ls -al snafu.html 
-rw-rw-r--  1 tdavis tdavis 12 May 28 19:56 snafu.html
&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://basement.dnsalias.net/~tdavis/snafu.html&quot;&gt;http://basement.dnsalias.net/~tdavis/snafu.html&lt;/a&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Forbidden&lt;br /&gt;&lt;br /&gt;You don&apos;t have permission to access /~tdavis/snafu.html on this server.&lt;br /&gt;&lt;br /&gt;Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.&lt;br /&gt;&lt;br /&gt;Apache/2.0.52 (Fedora) Server at basement.dnsalias.net Port 80&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Nope.&lt;br /&gt;&lt;br /&gt;Mabye if I kill httpd I can su into the apache user and test the file access.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement public_html]$ sudo /sbin/service httpd stop
Stopping httpd: [  OK  ]
[tdavis@basement public_html]$ su
Password: 
[root@basement public_html]# su apache
This account is currently not available.
&lt;/pre&gt;&lt;br /&gt;Nope.&lt;br /&gt;&lt;br /&gt;This has &lt;em&gt;got&lt;/em&gt; to be a farking configuration problem!  Right?  Oh what I wouldn&apos;t pay for some... oh wait, paying would defeat the purpose of using free software.  Ah, the fool I am.&lt;br /&gt;&lt;br /&gt;I&apos;m peeking at the configuration file again... because I&apos;m stubborn like that.  Time to delve a little deeper into each part of the access control settings.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://httpd.apache.org/docs-2.0/mod/core.html#limit&quot;&gt;http://httpd.apache.org/docs-2.0/mod/core.html#limit&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://httpd.apache.org/docs-2.0/mod/core.html#limitexcept&quot;&gt;http://httpd.apache.org/docs-2.0/mod/core.html#limitexcept&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://httpd.apache.org/docs-2.0/mod/mod_access.html#order&quot;&gt;http://httpd.apache.org/docs-2.0/mod/mod_access.html#order&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://httpd.apache.org/docs-2.0/mod/core.html#options&quot;&gt;http://httpd.apache.org/docs-2.0/mod/core.html#options&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It all looks good.  Argh.&lt;br /&gt;&lt;br /&gt;Is there anything more frustrating than something that &lt;em&gt;should&lt;/em&gt; work doesn&apos;t?  My problem is probably something incredibly simple that a veteran Apache administrator would notice in a blink of the eye, but it&apos;s stumped me for days now, and I&apos;m no closer to a solution.</description>
  <comments>http://trak3r.livejournal.com/52381.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/52147.html</guid>
  <pubDate>Sat, 28 May 2005 21:28:23 GMT</pubDate>
  <title>Apache Woes, Part Three</title>
  <link>http://trak3r.livejournal.com/52147.html</link>
  <description>OK let&apos;s get this file permission theory settled once and for all...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement conf]$ su
Password: 
[root@basement conf]# su apache
This account is currently not available.
&lt;/pre&gt;&lt;br /&gt;Sigh.  So much for that idea.&lt;br /&gt;&lt;br /&gt;Maybe I need an .htaccess file.  Oh this is going to get ugly.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://httpd.apache.org/docs-2.1/howto/htaccess.html&quot;&gt;http://httpd.apache.org/docs-2.1/howto/htaccess.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;OK that was nigh-useless.  How about another?&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://httpd.apache.org/docs-2.1/sections.html&quot;&gt;http://httpd.apache.org/docs-2.1/sections.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Nope, not much help either.  The core configuration file implies that my directory should be wide open to the world.  I&apos;m frustrated and infuriated at this point.&lt;br /&gt;&lt;br /&gt;How about another trip to the FAQ?&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Why do I get a &quot;Forbidden/You don&apos;t have permission to access / on this server&quot; message whenever I try to access my server?&lt;br /&gt;&lt;br /&gt;Search your conf/httpd.conf file for this exact string: &amp;lt;Files ~&amp;gt;. If you find it, that&apos;s your problem -- that particular &amp;lt;Files&amp;gt; container is malformed. Delete it or replace it with &amp;lt;Files ~ &quot;^\.ht&quot;&amp;gt; and restart your server and things should work as expected.&lt;br /&gt;&lt;br /&gt;This error appears to be caused by a problem with the version of linuxconf distributed with Redhat 6.x. It may reappear if you use linuxconf again.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;OK, that sounds promising...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement public_html]$ grep &quot;&amp;lt;Files&quot; /etc/httpd/conf/httpd.conf
&amp;lt;Files ~ &quot;^\.ht&quot;&amp;gt;
&lt;/pre&gt;&lt;br /&gt;Nope, we&apos;re fine there.&lt;br /&gt;&lt;br /&gt;How can a tool as prevalent as Apache be so convoluted to configure and so damn hard to troubleshoot!?  This is fscking ridiculous!  I&apos;ve now lost days of potential productivity because I can&apos;t figure out how to publish a damn file.&lt;br /&gt;&lt;br /&gt;Once again I bang my head against the configuration file to reiterate the obvious...&lt;br /&gt;&lt;pre&gt;
# The path to the end user account &apos;public_html&apos; directory must be
# accessible to the webserver userid.  This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a &quot;403 Forbidden&quot; message.
&lt;/pre&gt;&lt;br /&gt;And for sanity sake...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement public_html]$ pwd
/home/tdavis/public_html
[tdavis@basement public_html]$ ls -al
total 24
drwxr-xr-x   2 tdavis tdavis 4096 May 28 17:06 .
drwx--x--x  17 tdavis tdavis 4096 May 28 08:34 ..
-rw-rw-r--   1 tdavis tdavis   12 May 28 08:34 index.html
&lt;/pre&gt;&lt;br /&gt;Yup, exactly what it says.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://basement.dnsalias.net/~tdavis/index.html&quot;&gt;http://basement.dnsalias.net/~tdavis/index.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Forbidden&lt;br /&gt;&lt;br /&gt;You don&apos;t have permission to access /~tdavis/index.html on this server.&lt;br /&gt;&lt;br /&gt;Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.&lt;br /&gt;&lt;br /&gt;Apache/2.0.52 (Fedora) Server at basement.dnsalias.net Port 80&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Sigh.  Huh?  What&apos;s that part about an error trying to use an ErrorDocument?  Something &lt;em&gt;else&lt;/em&gt; is broken too?  Or is this perhaps related?&lt;br /&gt;&lt;br /&gt;I don&apos;t know why Apache isn&apos;t/can&apos;t/won&apos;t serve the error documents, but I found it on the drive and read the contents:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;You don&apos;t have permission to access the requested directory.&lt;br /&gt;There is either no index document or the directory is read-protected.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;The first part is obvious; I know it&apos;s not permitting me to access the directory.  The second part is quite simply wrong; there &lt;em&gt;is&lt;/em&gt; an index document and it &lt;em&gt;is not&lt;/em&gt; read-protected.  WTF!?&lt;br /&gt;&lt;br /&gt;I&apos;m too pissed to continue.</description>
  <comments>http://trak3r.livejournal.com/52147.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/51783.html</guid>
  <pubDate>Sat, 28 May 2005 20:40:34 GMT</pubDate>
  <title>Katamari Damacy</title>
  <link>http://trak3r.livejournal.com/51783.html</link>
  <description>I got this game for my daughter for her birthday.  We&apos;ve been playing it all day.  It&apos;s fantastic.  It&apos;s a testament to the old adage that simplicity is king.  The goal of the game: roll a ball around and things stick to it.  That&apos;s it!  It&apos;s easy.  It&apos;s fun.  It&apos;s entertaining.  Even the head-to-head is a blast.  You can get your opponent&apos;s ball stuck to your ball if you&apos;ve got the size advantage, then they have to shake themselves off while you use your temporarily boosted girth to stick even bigger stuff.  Oh, and the soundtrack is mostly classic big-band jazz tunes sung in Japanese -- hilarious!  My daughter sings along with the scatting sections.  The plot, if you can call it that, is animated like it was ripped out of an old Beatles animation (like Yellow Submarine or Sergeant Pepper).  It&apos;s psychedelic!  We&apos;re loving every second of it.</description>
  <comments>http://trak3r.livejournal.com/51783.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/51625.html</guid>
  <pubDate>Sat, 28 May 2005 16:10:46 GMT</pubDate>
  <title>Apache Woes, Part Two</title>
  <link>http://trak3r.livejournal.com/51625.html</link>
  <description>It suddenly came back to me.  I recall in the olden days of yore, you could configure Apache to let users host websites from their home directories as long as they all followed the convention of created a directory under their relative home directory named public_html.  This probably isn&apos;t enable by default, but let&apos;s clean up my former mess and try it...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ rm basement/test.html 
[tdavis@basement ~]$ rmdir basement/
[tdavis@basement ~]$ mkdir public_html
[tdavis@basement ~]$ cd public_html/
[tdavis@basement public_html]$ echo &quot;hello world&quot; &amp;gt; index.html
[tdavis@basement public_html]$ ls -al
total 24
drwxrwxr-x   2 tdavis tdavis 4096 May 28 08:34 .
drwxr-xr-x  17 tdavis tdavis 4096 May 28 08:34 ..
-rw-rw-r--   1 tdavis tdavis   12 May 28 08:34 index.html
&lt;/pre&gt;&lt;br /&gt;That all looks good.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://basement.dnsalias.net/~tdavis/index.html&quot;&gt;http://basement.dnsalias.net/~tdavis/index.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I&apos;m starting to wonder if the user account that&apos;s running Apache simply doesn&apos;t have permission to read the tdavis files and directories... but before I investigate that, I&apos;m going to take one more crack as the configuration file.&lt;br /&gt;&lt;br /&gt;Oh yeah, I forgot to clean up one thing.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement public_html]$ cd /var/www/html/
[tdavis@basement html]$ ls -al
total 20
drwxr-xr-x  2 root root 4096 May 26 21:32 .
drwxr-xr-x  8 root root 4096 Nov 11  2004 ..
lrwxrwxrwx  1 root root   21 May 26 21:32 basement -&amp;gt; /home/tdavis/basement
[tdavis@basement html]$ sudo rm basement
&lt;/pre&gt;&lt;br /&gt;Alrighty.  I found and un-commented the following section of the configuration file:&lt;br /&gt;&lt;pre&gt;
#
# Control access to UserDir directories.  The following is an example
# for a site where these directories are restricted to read-only.
#
&amp;lt;Directory /home/*/public_html&amp;gt;
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    &amp;lt;Limit GET POST OPTIONS&amp;gt;
        Order allow,deny
        Allow from all
    &amp;lt;/Limit&amp;gt;
    &amp;lt;LimitExcept GET POST OPTIONS&amp;gt;
        Order deny,allow
        Deny from all
    &amp;lt;/LimitExcept&amp;gt;
&amp;lt;/Directory&amp;gt;
&lt;/pre&gt;&lt;br /&gt;And a quick restart.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement conf]$ sudo /sbin/service httpd restart
&lt;/pre&gt;&lt;br /&gt;Nope.  Perhaps I missed something else... ah, here we go:&lt;br /&gt;&lt;pre&gt;
&amp;lt;IfModule mod_userdir.c&amp;gt;
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
    UserDir disable

    #
    # To enable requests to /~user/ to serve the user&apos;s public_html
    # directory, remove the &quot;UserDir disable&quot; line above, and uncomment
    # the following line instead:
    #
    #UserDir public_html

&amp;lt;/IfModule&amp;gt;
&lt;/pre&gt;&lt;br /&gt;Another restart and... bam!  Hmm, still can&apos;t load the page, but the error message changed from &quot;Not Found&quot; to &quot;Forbidden&quot;.  That&apos;s a good sign... isn&apos;t it?&lt;br /&gt;&lt;br /&gt;Here&apos;s another clue...&lt;br /&gt;&lt;pre&gt;
# The path to the end user account &apos;public_html&apos; directory must be
# accessible to the webserver userid.  This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a &quot;403 Forbidden&quot; message.
#
# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
&lt;/pre&gt;&lt;br /&gt;This points back to my original theory that the user running Apache doesn&apos;t have access to my home directory.  But it &lt;em&gt;is&lt;/em&gt; world readable, so I&apos;m stumped.  Let&apos;s check out the URL listed in the comments...&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;14. Why do I get a &quot;Forbidden&quot; message whenever I try to access a particular directory?&lt;br /&gt;&lt;br /&gt;This message is generally caused because either&lt;br /&gt;&lt;br /&gt;    * The underlying file system permissions do not allow the User/Group under which Apache is running to access the necessary files; or&lt;br /&gt;    * The Apache configuration has some access restrictions in place which forbid access to the files.&lt;br /&gt;&lt;br /&gt;You can determine which case applies to your situation by checking the error log.&lt;br /&gt;&lt;br /&gt;In the case where file system permission are at fault, remember that not only must the directory and files in question be readable, but also all parent directories must be at least searchable (i.e., chmod +x /directory/path) by the web server in order for the content to be accessible.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Ah, there&apos;s an error log?  Duh!  Let&apos;s check that out...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement public_html]$ cd /etc/httpd/logs/
-bash: cd: /etc/httpd/logs/: Permission denied
&lt;/pre&gt;&lt;br /&gt;Grr...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement public_html]$ su
Password: 
[root@basement public_html]# cd /etc/httpd/logs
[root@basement logs]# ls
access_log    error_log    ssl_access_log  ssl_request_log
access_log.1  error_log.1  ssl_error_log
[root@basement logs]# tail error_log
...
[Sat May 28 11:54:18 2005] [error] [client 24.233.173.197] (13)Permission 
    denied: access to /~tdavis denied
&lt;/pre&gt;&lt;br /&gt;OK, permission denied, by what?  The file access settings?  The httpd configuration settings?  No help there.  So much for &quot;You can determine which case applies to your situation by checking the error log.&quot;  Lies, all lies!&lt;br /&gt;&lt;br /&gt;The file access settings look fine to me.  Everything is world-readable.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement public_html]$ ls -al
total 24
drwxr-xr-x   2 tdavis tdavis 4096 May 28 08:34 .
drwx--x--x  17 tdavis tdavis 4096 May 28 08:34 ..
-rw-rw-r--   1 tdavis tdavis   12 May 28 08:34 index.html
&lt;/pre&gt;&lt;br /&gt;One more peek at the configuration file... nope, nothing evident there.  Another frustrating fruitless session.  Sigh.</description>
  <comments>http://trak3r.livejournal.com/51625.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/51232.html</guid>
  <pubDate>Fri, 27 May 2005 20:32:03 GMT</pubDate>
  <title>RedHat Woes Update</title>
  <link>http://trak3r.livejournal.com/51232.html</link>
  <description>Through the window manager, I found a GUI that allowed me to make Apache and PostgreSQL start up when the machine boots.  I have no idea WTF it did behind the scenes.  If I didn&apos;t have access to the GUI, if this box had been racked a couple weeks ago like I had planned, I&apos;d still be screwed.  Let&apos;s hear it for procrastination!</description>
  <comments>http://trak3r.livejournal.com/51232.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/51139.html</guid>
  <pubDate>Fri, 27 May 2005 14:25:28 GMT</pubDate>
  <title>RedHat Woes, Part One</title>
  <link>http://trak3r.livejournal.com/51139.html</link>
  <description>Before I continue, I need to fix something that&apos;s irking me.  Apache and PostgreSQL are not starting up when the machine reboots.  I have Googled my nads off and come up dry with a solution to this (much to my dismay -- can my faith in FOSS dwindle any more?).  No help from RedHat&apos;s knowledge base, none from Apache, not even PostgreSQL&apos;s web site.  I tried all the cockamamie Apache suggestions from non-official blogs and forums and none have worked.  Here&apos;s the less cryptic of them all...&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;a href=&quot;http://sol4.net/linux/apache1.shtml&quot;&gt;http://sol4.net/linux/apache1.shtml&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Starting Apache under Redhat&lt;br /&gt;&lt;br /&gt;Under Redhat, to start Apache at boot time you, after logging in as root, you need to create the following link.&lt;br /&gt;&lt;br /&gt;ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;... but, it didn&apos;t work.  So I&apos;m moving on to PostgreSQL.  This one solution looks promising...&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;a href=&quot;http://www.openmicroscopy.org/install/redhat.html&quot;&gt;http://www.openmicroscopy.org/install/redhat.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You will probably want PostgreSQL to start on boot. The init script, which automates startup and shutdown, is already copied to the init.d directory by the rpm install. You just have to turn it on to the appropriate run levels.&lt;br /&gt;&lt;br /&gt;chkconfig --level 345 postgresql&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;pre&gt;
[tdavis@basement init.d]$ sudo /sbin/chkconfig --level 345 postgresql
only one runlevel may be specified for a chkconfig query
&lt;/pre&gt;&lt;br /&gt;Oh really?  That&apos;s not what the man page says...&lt;br /&gt;&lt;pre&gt;
--level levels
    Specifies the run levels an operation should pertain  to.  It  is
    given as a string of numbers from 0 to 7. For example, --level 35
    specifies runlevels 3 and 5.
&lt;/pre&gt;&lt;br /&gt;Sigh.  Chalk up yet another soul-crushing defeat at the hands of FOSS.  This is depressing.</description>
  <comments>http://trak3r.livejournal.com/51139.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/50777.html</guid>
  <pubDate>Fri, 27 May 2005 01:52:06 GMT</pubDate>
  <title>Apache Woes, Part One</title>
  <link>http://trak3r.livejournal.com/50777.html</link>
  <description>OK, I&apos;ve got a default RedHat Linux install with a default Apache install.  Let&apos;s see what going on there...&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://basement.dnsalias.net/&quot;&gt;http://basement.dnsalias.net/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&quot;The operation timed out when attempting to contact basement.dnsalias.net.&quot;&lt;br /&gt;&lt;br /&gt;Hmm, that&apos;s a good sign that Apache isn&apos;t running.  Fortunately for me, I&apos;ve worked with Apache before, so this shouldn&apos;t be too hard to figure out...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ sudo /usr/sbin/apachectl start
&lt;/pre&gt;&lt;br /&gt;Much better.  Now I can see the Fedora Core Test Page.  We&apos;re rolling now.  Let&apos;s set up a working directory in my home directory and see if I can get Apache to serve it...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ pwd
/home/tdavis
[tdavis@basement ~]$ mkdir basement
[tdavis@basement ~]$ ls -al basement
total 16
drwxrwxr-x   2 tdavis tdavis 4096 May 26 21:19 .
drwx------  17 tdavis tdavis 4096 May 26 21:19 ..
&lt;/pre&gt;&lt;br /&gt;There&apos;s the directory, and it&apos;s got good permissions (everybody can read).  Now I need to find the Apache configuration file...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ find / -name httpd.conf &amp;gt; find 2&amp;gt; errors; cat find
/etc/httpd/conf/httpd.conf
&lt;/pre&gt;&lt;br /&gt;I really should macro that command; I use it all the time since I can never remember where anything is.  &lt;br /&gt;&lt;br /&gt;Time to load up emacs and take a peek...&lt;br /&gt;&lt;br /&gt;Wow!  Look at the bazillion configuration variables.  Holy macaroni!  There are 1005 lines in the configuration file.&lt;br /&gt;&lt;pre&gt;
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot &quot;/var/www/html&quot;
&lt;/pre&gt;&lt;br /&gt;Okie dokie, so that&apos;s where it&apos;s looking...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ cd /var/www/html
[tdavis@basement html]$ ls -al
total 16
drwxr-xr-x  2 root root 4096 Nov 11  2004 .
drwxr-xr-x  8 root root 4096 Nov 11  2004 ..
&lt;/pre&gt;&lt;br /&gt;Er... where&apos;s the Fedora Core Test Page that&apos;s being served?  This directory is empty!&lt;br /&gt;&lt;br /&gt;Ah, well, I&apos;ll worry about that later.  Let&apos;s see if I can create a symbolic link to the directory in my home directory and load a test page...&lt;br /&gt;&lt;pre&gt;
[tdavis@basement html]$ su
Password: 
[root@basement html]# ln /home/tdavis/basement basement
ln: `/home/tdavis/basement&apos;: hard link not allowed for directory
&lt;/pre&gt;&lt;br /&gt;Apparently I don&apos;t remember how to create a symbolic link.&lt;br /&gt;&lt;pre&gt;
[root@basement html]# ln /home/tdavis/basement basement --symbolic
[root@basement html]# ls -al
total 20
drwxr-xr-x  2 root root 4096 May 26 21:32 .
drwxr-xr-x  8 root root 4096 Nov 11  2004 ..
lrwxrwxrwx  1 root root   21 May 26 21:32 basement -&amp;gt; /home/tdavis/basement
&lt;/pre&gt;&lt;br /&gt;OK, that&apos;s better.&lt;br /&gt;&lt;pre&gt;
[root@basement html]# exit
[tdavis@basement html]$ cd
[tdavis@basement ~]$ cd basement/
[tdavis@basement basement]$ echo &quot;hello world&quot; &amp;gt; test.html
&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;http://basement.dnsalias.net/basement/test.html&quot;&gt;http://basement.dnsalias.net/basement/test.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&quot;Forbidden -- You don&apos;t have permission to access /basement/test.html on this server.&quot;&lt;br /&gt;&lt;br /&gt;Gah!  Perhaps Apache is configured to not follow symbolic links.&lt;br /&gt;&lt;br /&gt;Nope, I see &quot;FollowSymLinks&quot; for the root level directories in the config file.  &lt;br /&gt;&lt;br /&gt;Perhaps I screwed up the permissions on my file or home directory.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement basement]$ ls -al
total 24
drwxrwxr-x   2 tdavis tdavis 4096 May 26 21:33 .
drwx------  17 tdavis tdavis 4096 May 26 21:21 ..
-rw-rw-r--   1 tdavis tdavis   12 May 26 21:34 test.html
&lt;/pre&gt;&lt;br /&gt;Yup, that looks like it.  My home directory is locked up.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement basement]$ chmod 755 ..
[tdavis@basement basement]$ ls -al
total 24
drwxrwxr-x   2 tdavis tdavis 4096 May 26 21:33 .
drwxr-xr-x  17 tdavis tdavis 4096 May 26 21:21 ..
-rw-rw-r--   1 tdavis tdavis   12 May 26 21:34 test.html
&lt;/pre&gt;&lt;br /&gt;Hmm, that didn&apos;t fix it.  Perhaps Apache needs to be restarted.  I can&apos;t imagine that&apos;s the case, but my Unix-fu is very rusty, so I might as well try.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement basement]$ sudo /sbin/service httpd restart
Stopping httpd: [  OK  ]
Starting httpd: [  OK  ]
&lt;/pre&gt;&lt;br /&gt;Note that I used the RedHat convenience tool &quot;service&quot; this time.  But alas it did not solve the problem.  I still can&apos;t access my test page.&lt;br /&gt;&lt;br /&gt;Hmm, I have a theory that /var/www/html is &lt;em&gt;not&lt;/em&gt; the correct directory.  My first clue is that it&apos;s empty yet Apache is serving a default page.&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ find / -name index.html &amp;gt;find 2&amp;gt;errors; cat find
/var/www/usage/index.html
/var/www/manual/index.html
...
..
.
&lt;/pre&gt;&lt;br /&gt;115 files and none of them look to be my target.  Grr.  OK, Apache, you&apos;ve won this battle, but I&apos;ll be back to fight another day.  Mark my words!</description>
  <comments>http://trak3r.livejournal.com/50777.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/50599.html</guid>
  <pubDate>Thu, 26 May 2005 21:53:10 GMT</pubDate>
  <title>PostgreSQL Woes, Part Six</title>
  <link>http://trak3r.livejournal.com/50599.html</link>
  <description>Alright, I hope this will be my last session with PostgreSQL for the time being.  There&apos;s two last things I want to bang out before I move on the PHP experimentation: indexes and referential integrity.&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; \d users
                        Table &quot;public.users&quot;
  Column  |  Type   |                   Modifiers                    
----------+---------+------------------------------------------------
 username | text    | 
 password | text    | 
 e-mail   | text    | 
 id       | integer | not null default nextval(&apos;users_id_seq&apos;::text)
Indexes:
    &quot;users_pkey&quot; primary key, btree (id)
    &quot;e-mail_key&quot; unique, btree (&quot;e-mail&quot;)
    &quot;username_key&quot; unique, btree (username)
&lt;/pre&gt;&lt;br /&gt;Good, my table is still there.  Ya never know.  My initial plan was to add an index to username, but I now see that it already has one as a result of its unique constraint.  For the purposes of this experiment, I&apos;m going to index password too.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.0/interactive/indexes.html&quot;&gt;http://www.postgresql.org/docs/8.0/interactive/indexes.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Looks simple enough...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; create index password_index on users (password);
CREATE INDEX
basement=&amp;gt; \d users
                        Table &quot;public.users&quot;
  Column  |  Type   |                   Modifiers                    
----------+---------+------------------------------------------------
 username | text    | 
 password | text    | 
 e-mail   | text    | 
 id       | integer | not null default nextval(&apos;users_id_seq&apos;::text)
Indexes:
    &quot;users_pkey&quot; primary key, btree (id)
    &quot;e-mail_key&quot; unique, btree (&quot;e-mail&quot;)
    &quot;username_key&quot; unique, btree (username)
    &quot;password_index&quot; btree (&quot;password&quot;)
&lt;/pre&gt;&lt;br /&gt;And it is!  Excellent.  Now let&apos;s try some referential integrity.  First I need a second table so I can tie the two together...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; create table toy ( id serial primary key, userid integer, name text );
NOTICE:  CREATE TABLE will create implicit sequence &quot;toy_id_seq&quot; 
    for &quot;serial&quot; column &quot;toy.id&quot;
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 
    &quot;toy_pkey&quot; for table &quot;toy&quot;
CREATE TABLE
basement=&amp;gt; \d toy
                           Table &quot;public.toy&quot;
 Column |  Type   |                      Modifiers                      
--------+---------+-----------------------------------------------------
 id     | integer | not null default nextval(&apos;public.toy_id_seq&apos;::text)
 userid | integer | 
 name   | text    | 
Indexes:
    &quot;toy_pkey&quot; primary key, btree (id)
&lt;/pre&gt;&lt;br /&gt;Fantastic.  Now I need to tie toy.userid to users.id.  Hmm, I can&apos;t find any clear documentation on the syntax for this, but there is one example on this page:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.0/interactive/sql-altertable.html&quot;&gt;http://www.postgresql.org/docs/8.0/interactive/sql-altertable.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I&apos;ll just copy it and see what comes of it...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table toy add constraint toy_user_id_fk foreign 
    key ( userid ) references users ( id ) match full;
ALTER TABLE
basement=&amp;gt; \d toy
                           Table &quot;public.toy&quot;
 Column |  Type   |                      Modifiers                      
--------+---------+-----------------------------------------------------
 id     | integer | not null default nextval(&apos;public.toy_id_seq&apos;::text)
 userid | integer | 
 name   | text    | 
Indexes:
    &quot;toy_pkey&quot; primary key, btree (id)
Foreign-key constraints:
    &quot;toy_user_id_fk&quot; FOREIGN KEY (userid) REFERENCES users(id) MATCH FULL
&lt;/pre&gt;&lt;br /&gt;OK, that looks right.  But I&apos;m going to look up that &quot;match full&quot; part for good measure... hmm, that was harder to find than I expected, but it&apos;s buried at:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html&quot;&gt;http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;... and it reads as, &quot;MATCH FULL will not allow one column of a multicolumn foreign key to be null unless all foreign key columns are null. MATCH SIMPLE allows some foreign key columns to be null while other parts of the foreign key are not null. MATCH PARTIAL is not yet implemented.&quot;&lt;br /&gt;&lt;br /&gt;Hmm, interesting.  Not really apropos in my test since I&apos;m not using a multicolumn foreign key, but I&apos;m glad I stumbled onto it so I&apos;m wary of it if and when I need it.&lt;br /&gt;&lt;br /&gt;And that concludes my quick and dirty immersion into PostgreSQL.  I&apos;ll be coming back to it when it&apos;s time to start building the &quot;real deal&quot;, but for now I&apos;m going to move on to PHP and see what exciting new headaches it has in store for me...</description>
  <comments>http://trak3r.livejournal.com/50599.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/50398.html</guid>
  <pubDate>Wed, 25 May 2005 18:38:23 GMT</pubDate>
  <title>Jury Duty</title>
  <link>http://trak3r.livejournal.com/50398.html</link>
  <description>I&apos;m 33 years old and have never been summoned for jury duty... until now.  I&apos;ve heard a few horror stories about it.  Tomorrow I have to schlep down to the courthouse and experience it for myself.  I&apos;m rather apathetic about it.  I don&apos;t care about losing a day of work.  I&apos;m interested to see what it&apos;s like.  But I&apos;m neither excited nor depressed about it.  The only thing I don&apos;t want to do is sit on my ass all day waiting for my number to be called.  I&apos;ll have a couple books with me.  I wonder if I can get my iPod past security.</description>
  <comments>http://trak3r.livejournal.com/50398.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/50060.html</guid>
  <pubDate>Wed, 25 May 2005 13:07:41 GMT</pubDate>
  <title>Screw Frameworks</title>
  <link>http://trak3r.livejournal.com/50060.html</link>
  <description>The last few weekends I&apos;ve been reading about PHP frameworks.  I&apos;ve come to realize the following:&lt;br /&gt;&lt;br /&gt;- Nobody agrees on which ones are &quot;good&quot;.&lt;br /&gt;&lt;br /&gt;- Nobody agrees on what a &quot;good&quot; framework should do.&lt;br /&gt;&lt;br /&gt;And the more I think about it, the more I realize that using a framework is going to defeat my goal of learning PHP.  A framework is going to abstract all the knitty gritty and prevent me from knowing what&apos;s really going on.  Sure, a &quot;good&quot; framework should technically allow me to get my project implemented quickly and painlessly, which is one of my goals, but in this case I&apos;m willing to endure a little pain to get my hands dirty.  I won&apos;t be using a framework.  I&apos;m going to be reinventing some wheels.&lt;br /&gt;&lt;br /&gt;But before I get to the coding, I have at least one more session with the database, which should be my next entry.&lt;br /&gt;&lt;br /&gt;And after my feet are sufficiently wet with database and php moisture, I&apos;ll need to set up some revision control system.</description>
  <comments>http://trak3r.livejournal.com/50060.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/49702.html</guid>
  <pubDate>Tue, 24 May 2005 15:49:13 GMT</pubDate>
  <title>PostgreSQL Woes, Part Five</title>
  <link>http://trak3r.livejournal.com/49702.html</link>
  <description>Now that I&apos;ve created a table, how do I review it?  What&apos;s the command to show me the table design?  I&apos;m not having any luck with the documentation.  I listed all the available commands.  The obvious ones didn&apos;t do what I expected...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; \h analyze
Command:     ANALYZE
Description: collect statistics about a database
Syntax:
ANALYZE [ VERBOSE ] [ table [ (column [, ...] ) ] ]

basement=&amp;gt; \h explain
Command:     EXPLAIN
Description: show the execution plan of a statement
Syntax:
EXPLAIN [ ANALYZE ] [ VERBOSE ] statement

basement=&amp;gt; \h show
Command:     SHOW
Description: show the value of a run-time parameter
Syntax:
SHOW name
SHOW ALL
&lt;/pre&gt;&lt;br /&gt;Ah!  I stumbled upon it quite by accident...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; \d users
                        Table &quot;public.users&quot;
  Column  |  Type   |                   Modifiers                    
----------+---------+------------------------------------------------
 username | text    | 
 password | text    | 
 e-mail   | text    | 
 id       | integer | not null default nextval(&apos;users_id_seq&apos;::text)
Indexes:
    &quot;users_pkey&quot; primary key, btree (id)
    &quot;e-mail_key&quot; unique, btree (&quot;e-mail&quot;)
    &quot;username_key&quot; unique, btree (username)
&lt;/pre&gt;&lt;br /&gt;Hmm, what is that &quot;::text&quot; after the sequence reference?  That&apos;s a cause for concern.  The sequence should be a series of integers.  What does that suffix mean?&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.0/interactive/sql-createsequence.html&quot;&gt;http://www.postgresql.org/docs/8.0/interactive/sql-createsequence.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The documentation is no help.  Searching comes up dry as well.  Grr.  Something is fishy, and I don&apos;t like it.&lt;br /&gt;&lt;br /&gt;Let&apos;s create a temporary test table using the &quot;serial&quot; data type then see what it dumps...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; create table harbinger ( magic serial );
NOTICE:  CREATE TABLE will create implicit sequence &quot;harbinger_magic_seq&quot; 
    for &quot;serial&quot; column &quot;harbinger.magic&quot;
CREATE TABLE
basement=&amp;gt; \d harbinger
                            Table &quot;public.harbinger&quot;
 Column |  Type   |                          Modifiers                           
--------+---------+--------------------------------------------------------------
 magic  | integer | not null default nextval(&apos;public.harbinger_magic_seq&apos;::text)
&lt;/pre&gt;&lt;br /&gt;Hmm, it also has the &quot;::text&quot; suffix.  OK.  I&apos;m not going to worry about that any more for now.&lt;br /&gt; &lt;br /&gt;Oh yeah, I need to clean up...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; drop table harbinger;
DROP TABLE
&lt;/pre&gt;&lt;br /&gt;But wait a second.  It said it was creating the implicit sequence for me.  When I dropped the table, did it clean up the orphaned sequence too?&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; \d harbinger_magic_seq
Did not find any relation named &quot;harbinger_magic_seq&quot;.
&lt;/pre&gt;&lt;br /&gt;Good boy!  Ah, I should be able to check out my users id sequence as well...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; \d users_id_seq
Sequence &quot;public.users_id_seq&quot;
    Column     |  Type   
---------------+---------
 sequence_name | name
 last_value    | bigint
 increment_by  | bigint
 max_value     | bigint
 min_value     | bigint
 cache_value   | bigint
 log_cnt       | bigint
 is_cycled     | boolean
 is_called     | boolean
 &lt;/pre&gt;&lt;br /&gt; Excellent.  No &quot;text&quot; in there that I can see.  I guess I&apos;ll never know what that suffix meant :-\</description>
  <comments>http://trak3r.livejournal.com/49702.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://trak3r.livejournal.com/49508.html</guid>
  <pubDate>Tue, 24 May 2005 00:15:33 GMT</pubDate>
  <title>PostgreSQL Woes, Part Four</title>
  <link>http://trak3r.livejournal.com/49508.html</link>
  <description>Now that I&apos;ve got an operational, I&apos;m ready to create some tables...&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.0/interactive/ddl.html#DDL-BASICS&quot;&gt;http://www.postgresql.org/docs/8.0/interactive/ddl.html#DDL-BASICS&lt;/a&gt;&lt;br /&gt;&lt;pre&gt;
[tdavis@basement ~]$ psql basement
Welcome to psql 7.4.8, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

basement=&amp;gt;
&lt;/pre&gt;&lt;br /&gt;Ah, good, everything still works.  Not that I had any doubts, of course...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; create table Users();
CREATE TABLE
basement=&amp;gt; select * from Users;
  
--
(0 rows)
&lt;/pre&gt;&lt;br /&gt;Excellent.&lt;br /&gt;&lt;br /&gt;Yeah, I&apos;m pluralizing the names of the tables.  I&apos;m intimately familiar with the debates.  That&apos;s the way I&apos;m doing it for this project.  So sue me :-P&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table Users add column Username text;
ALTER TABLE
basement=&amp;gt; alter table Users add column Password text;
ALTER TABLE
basement=&amp;gt; alter table Users add column E-mail text;
ERROR:  syntax error at or near &quot;-&quot; at character 31
&lt;/pre&gt;&lt;br /&gt;Hmm, can&apos;t have a hyphen in a column name?  Perhaps if I quoted the name.  How do I do that?  No help from the docs...&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.0/interactive/sql-altertable.html&quot;&gt;http://www.postgresql.org/docs/8.0/interactive/sql-altertable.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So let&apos;s experiment...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table Users add column &quot;E-mail&quot; text;
ALTER TABLE
&lt;/pre&gt;&lt;br /&gt;OK, that created the column, but did it include the quotes in the name?  You never know.&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; select * from Users;
 username | password | E-mail 
----------+----------+--------
(0 rows)
&lt;/pre&gt;&lt;br /&gt;That looks good... but wait a second.  Why did it make &quot;username&quot; and &quot;password&quot; lowercase?  Grr!  OK, I&apos;m not going to screw around with this case-sensitive crap.  I&apos;m going all lower-case...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table users rename &quot;E-mail&quot; to &quot;e-mail&quot;;
ALTER TABLE
basement=&amp;gt; select * from users;
 username | password | e-mail 
----------+----------+--------
(0 rows)
&lt;/pre&gt;&lt;br /&gt;That&apos;s more like it.  Now how do I add an auto-incrementing primary key?&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html&quot;&gt;http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Ah cool, there&apos;s a special type called &quot;serial&quot; that acts as shorthand for &quot;integer DEFAULT nextval(&apos;tablename_colname_seq&apos;) NOT NULL&quot;... &lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table users add column id serial;
NOTICE:  ALTER TABLE will create implicit sequence &quot;users_id_seq&quot; 
    for &quot;serial&quot; column &quot;users.id&quot;
ERROR:  adding columns with defaults is not implemented
HINT:  Add the column, then use ALTER TABLE SET DEFAULT.
&lt;/pre&gt;&lt;br /&gt;Hmm, OK, let&apos;s try it the long way...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table users add column id integer default 
    nextval(&apos;users_id_seq&apos;) not null;
ERROR:  adding columns with defaults is not implemented
HINT:  Add the column, then use ALTER TABLE SET DEFAULT.
&lt;/pre&gt;&lt;br /&gt;Grr...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table users add column id integer not null;
ERROR:  adding NOT NULL columns is not implemented
HINT:  Add the column, then use ALTER TABLE SET NOT NULL.
&lt;/pre&gt;&lt;br /&gt;GRR!&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table users add column id integer;
ALTER TABLE
basement=&amp;gt; alter table users alter column id set not null;
ALTER TABLE
basement=&amp;gt; alter table users alter column id set default 
    nextval(&apos;users_id_seq&apos;);
ALTER TABLE
&lt;/pre&gt;&lt;br /&gt;A little more roundabout than I&apos;d like, but supposedly I arrived at the correct destination.  Did I get it all?  Oh yeah, I need it to be the primary key...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table users add primary key (id);
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index 
    &quot;users_pkey&quot; for table &quot;users&quot;
ALTER TABLE
&lt;/pre&gt;&lt;br /&gt;Let&apos;s test it...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; insert into users ( username, password, &quot;e-mail&quot; ) 
    values ( &apos;tdavis&apos;, &apos;secret&apos;, &apos;trak3r@hotmail.com&apos; );
ERROR:  relation &quot;users_id_seq&quot; does not exist
&lt;/pre&gt;&lt;br /&gt;That&apos;s not good.  Looks like I need to create a sequence...&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.0/interactive/sql-createsequence.html&quot;&gt;http://www.postgresql.org/docs/8.0/interactive/sql-createsequence.html&lt;/a&gt;&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; create sequence users_id_seq;
CREATE SEQUENCE
&lt;/pre&gt;&lt;br /&gt;Alright, now about that insert...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; insert into users ( username, password, &quot;e-mail&quot; ) 
    values ( &apos;tdavis&apos;, &apos;secret&apos;, &apos;trak3r@hotmail.com&apos; );
INSERT 17158 1
&lt;/pre&gt;&lt;br /&gt;That looks promising...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; select * from users;
 username | password |       e-mail       | id 
----------+----------+--------------------+----
 tdavis   | secret   | trak3r@hotmail.com |  1
(1 row)
&lt;/pre&gt;&lt;br /&gt;Yeah baby!&lt;br /&gt;&lt;br /&gt;Now we&apos;re cooking.  Now I&apos;m happy.  I&apos;m finally making progress.  It&apos;s all downhill from here... yeah right.&lt;br /&gt;&lt;br /&gt;Now how do I make the username and e-mail columns unique?&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; alter table users add constraint username_key unique(username);
NOTICE:  ALTER TABLE / ADD UNIQUE will create implicit index 
    &quot;username_key&quot; for table &quot;users&quot;
ALTER TABLE
basement=&amp;gt; alter table users add constraint &quot;e-mail_key&quot; unique(&quot;e-mail&quot;);
NOTICE:  ALTER TABLE / ADD UNIQUE will create implicit index 
    &quot;e-mail_key&quot; for table &quot;users&quot;
ALTER TABLE
&lt;/pre&gt;&lt;br /&gt;Could it really be that easy?  Let&apos;s test it...&lt;br /&gt;&lt;pre&gt;
basement=&amp;gt; insert into users ( username, password, &quot;e-mail&quot; ) 
    values ( &apos;tdavis&apos;, &apos;secret&apos;, &apos;trak3r@hotmail.com&apos; );
ERROR:  duplicate key violates unique constraint &quot;username_key&quot;
basement=&amp;gt; insert into users ( username, password, &quot;e-mail&quot; ) 
    values ( &apos;tdavis2&apos;, &apos;secret&apos;, &apos;trak3r@hotmail.com&apos; );
ERROR:  duplicate key violates unique constraint &quot;e-mail_key&quot;
&lt;/pre&gt;&lt;br /&gt;Rawkin&apos;!</description>
  <comments>http://trak3r.livejournal.com/49508.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
