You first need to download and compile the imap extension. I got my instructions from http://au.php.net/imap.
Once I'd done that, I followed the instructions from http://www.moztips.com/php5_install/, adding --with-imap=/path/to/imap/source/ to the php configure statement.
If you're on jabber, send me your ID, and I'm happy to walk you through it when we're both online. On the other hand, I'm happy to make a copy of my php.cgi available for download.
I should point out that I'm no expert at compiling software under *nix, just learning as I go.
Rhino