I\’ve been fighting today with Apache2 and mod_auth_pam which didn\’t want to go well with me. Finally I found this nice post which gave me almost full solution. The only thing to do is to give apache somehow access to read /etc/shadow (for example by chgrp apache /etc/shadow && chmod g+r /etc/shadow).
If you have some better ideas on how to make apache 2 to authorize system users, you are welcome :)