You might consider the "mod_auth_*" modules for
apache and let the webserver handle the authentication.
Search for "mod_auth" here.
There's several I see there that would support using
the unix passwords for authentication. ( mod_auth_external,
mod_auth_pamacea, mod_auth_shadow, etc )