Problem mit der Postgres-Authentifizierung über Apache

Problem mit der Postgres-Authentifizierung über Apache

Ich verwende RHEL 5.4 und habe eineDjangoProjekt mit PostgreSQL als Datenbank (ich habe vorher MySQL verwendet, möchte aber etwas Neues ausprobieren :)). Wenn ich den Django-Testserver ausführe, funktioniert alles, ich kann mich auch über die Befehlszeile mit Kennwortauthentifizierung verbinden:

psql -U myuser -h 127.0.0.1

Aber wenn ich versuche, über Apache auf mein Projekt zuzugreifen, erhalte ich einen 500-Fehlercode und diesen Python-Traceback im Fehlerprotokoll von Apache:

mod_wsgi (pid=7026): Exception occurred processing WSGI script '/var/www/myproject/myproject/hook.wsgi'.
Traceback (most recent call last):
  File "/var/www/myproject/myproject/src/django/django/core/handlers/wsgi.py", line 245, in __call__
    response = middleware_method(request, response)
  File "/var/www/myproject/myproject/src/django/django/contrib/sessions/middleware.py", line 36, in process_response
    request.session.save()
  File "/var/www/myproject/myproject/src/django/django/contrib/sessions/backends/db.py", line 55, in save
    obj = Session(
  File "/var/www/myproject/myproject/src/django/django/contrib/sessions/backends/base.py", line 152, in _get_session_key
    self._session_key = self._get_new_session_key()
  File "/var/www/myproject/myproject/src/django/django/contrib/sessions/backends/base.py", line 144, in _get_new_session_key
    if not self.exists(session_key):
  File "/var/www/myproject/myproject/src/django/django/contrib/sessions/backends/db.py", line 29, in exists
    Session.objects.get(session_key=session_key)
  File "/var/www/myproject/myproject/src/django/django/db/models/manager.py", line 132, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/var/www/myproject/myproject/src/django/django/db/models/query.py", line 336, in get
    num = len(clone)
  File "/var/www/myproject/myproject/src/django/django/db/models/query.py", line 81, in __len__
    self._result_cache = list(self.iterator())
  File "/var/www/myproject/myproject/src/django/django/db/models/query.py", line 269, in iterator
    for row in compiler.results_iter():
  File "/var/www/myproject/myproject/src/django/django/db/models/sql/compiler.py", line 672, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/var/www/myproject/myproject/src/django/django/db/models/sql/compiler.py", line 726, in execute_sql
    cursor = self.connection.cursor()
  File "/var/www/myproject/myproject/src/django/django/db/backends/__init__.py", line 75, in cursor
    cursor = self._cursor()
  File "/var/www/myproject/myproject/src/django/django/db/backends/postgresql_psycopg2/base.py", line 136, in _cursor
    self.connection = Database.connect(**conn_params)
OperationalError: could not connect to server: Permission denied
\tIs the server running on host "127.0.0.1" and accepting
\tTCP/IP connections on port 5432?

Ich habe das conn_paramsWörterbuch überprüft, es enthält den richtigen Benutzernamen und das richtige Passwort. Meins pg_hba.confsieht so aus (ich habe genau dieselbe Konfiguration auf einem Ubuntu 9.04-Server, wo alles prima funktioniert):

local   all         postgres                          ident
local   all         all                               md5
host    all         all         127.0.0.1/32          md5
host    all         all         ::1/128               md5

Was mache ich falsch?

Antwort1

Einer der häufigsten Fehler ist, das Passwort im Klartext anzugeben, obwohl lautpg_hba.confKonfiguration sollte es als MD5 angegeben werden.
Aktualisieren Sie das Passwort in Ihrer Konfigurationsdatei mit seinem MD5 und versuchen Sie es erneut. Sie können dafür jeden MD5-Generator verwenden, wieDieses hier.

verwandte Informationen