1. Check which user Apache server is running. In our eg. it is running by www-data
2. Change group ownership of /etc/shadow
chgrp www-data /etc/shadow
3. Install php5-auth-pam
3. Create login.html under webserver’s DocumentRoot and put below code under <html> tag
<form name="input" action="login.php" method="post">
Username: <input type="text" name="uname" /><br />
Password: <input type="password" name="pswd" />
<input type="submit" value="Submit" />
</form>
4. Create login.php in same folder and put below code
<?php
$uname = $_POST[‘uname’];
$pswd = $_POST[‘pswd’];
if ( pam_auth( $uname, $pswd, &$error ) ) {
echo "You are authenticated!";
} else {
echo $error;
}
?>
And check.. by using local username and password on server.