When facing login failures with phpPgAdmin, verify these critical configurations:
# pg_hba.conf excerpt (usually in /var/lib/pgsql/9.1/data/)
# TYPE DATABASE USER ADDRESS METHOD
host all all 127.0.0.1/32 md5
local all postgres md5
After modifying pg_hba.conf, remember to reload PostgreSQL:
service postgresql-9.1 reload
Create a dedicated user with proper privileges instead of using postgres directly:
CREATE USER webuser WITH PASSWORD 'SecurePass123';
GRANT ALL PRIVILEGES ON DATABASE postgres TO webuser;
ALTER USER webuser CREATEDB;
The config.inc.php needs these essential settings:
$conf['servers'][0]['host'] = 'localhost';
$conf['servers'][0]['port'] = 5432;
$conf['servers'][0]['sslmode'] = 'allow';
$conf['servers'][0]['extra_login_security'] = false;
// For debugging purposes
$conf['debug'] = true;
If you still experience login failures:
- Verify PostgreSQL is listening on the correct interface:
netstat -tulnp | grep 5432 - Test direct psql connection:
psql -h 127.0.0.1 -U webuser -d postgres - Check PHP error logs:
tail -f /var/log/httpd/error_log
- SELinux blocking connections (temporarily test with
setenforce 0) - PHP's pgsql extension not loaded (
php -m | grep pgsql) - Firewall rules blocking port 5432 or 80
For testing purposes, try connecting via UNIX socket:
$conf['servers'][0]['host'] = '';
$conf['servers'][0]['pg_dsn'] = 'pgsql:dbname=template1';
When phpPgAdmin stubbornly rejects valid credentials that work perfectly in psql, we're typically dealing with one of three fundamental issues:
// Common failure points:
1. pg_hba.conf misconfiguration
2. PHP/Apache environment issues
3. phpPgAdmin security restrictions
Your current MD5 setting is correct, but let's verify the complete authentication chain. The critical lines should resemble:
# TYPE DATABASE USER ADDRESS METHOD
local all postgres peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
After modifying pg_hba.conf, remember to reload PostgreSQL:
sudo service postgresql-9.1 reload
Beyond the basic settings you've already adjusted, these additional configurations often resolve login issues:
$conf['servers'][0]['port'] = 5432;
$conf['servers'][0]['sslmode'] = 'allow';
$conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump';
$conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall';
The webuser needs explicit login privileges. Verify with:
psql -U postgres -c "SELECT rolname, rolcanlogin FROM pg_roles WHERE rolname = 'webuser';"
If missing, grant access:
psql -U postgres -c "ALTER ROLE webuser WITH LOGIN;"
CentOS 6.2's default PHP settings might interfere with session handling. Check /etc/php.ini:
session.save_path = "/var/lib/php/session"
session.save_handler = files
Ensure the session directory exists and has proper permissions:
sudo mkdir -p /var/lib/php/session
sudo chown -R apache:apache /var/lib/php/session
Verify PHP can actually reach PostgreSQL:
Check these critical logs when issues persist:
tail -n 50 /var/log/httpd/error_log
tail -n 50 /var/lib/pgsql/9.1/data/pg_log/postgresql-*.log