Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django/modèwsgi/postgresqlèpsycopg2:can';t connect身份验证失败(但设置在django runserver或dbshell下工作正常)_Django_Postgresql_Apache2_Mod Wsgi - Fatal编程技术网

Django/modèwsgi/postgresqlèpsycopg2:can';t connect身份验证失败(但设置在django runserver或dbshell下工作正常)

Django/modèwsgi/postgresqlèpsycopg2:can';t connect身份验证失败(但设置在django runserver或dbshell下工作正常),django,postgresql,apache2,mod-wsgi,Django,Postgresql,Apache2,Mod Wsgi,我正在一个Ubuntu 8.10服务器上部署我的django站点,这是我从头开始设置的。我对这个完全陌生,所以可能有很多东西我错过了,但很高兴我找到了我的方法,部署了一个网站 我的最后一个障碍: 我收到postgresql的身份验证错误 [Sun Apr 19 18:44:05 2009] [error] [client 124.254.102.127] mod_wsgi (pid=30304): Exception occurred processing WSGI script '/hom

我正在一个Ubuntu 8.10服务器上部署我的django站点,这是我从头开始设置的。我对这个完全陌生,所以可能有很多东西我错过了,但很高兴我找到了我的方法,部署了一个网站

我的最后一个障碍:

我收到postgresql的身份验证错误

[Sun Apr 19 18:44:05 2009] [error] [client 124.254.102.127] 
 mod_wsgi (pid=30304): Exception occurred processing WSGI script '/home/acacian/webapps/acacian/deploy/acacian.wsgi'.
 Traceback (most recent call last):
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/handlers/wsgi.py", line 241, in __call__
     response = self.get_response(request)
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/handlers/base.py", line 73, in get_response
     response = middleware_method(request)
   File "/home/acacian/webapps/pinax-env/src/django-openid/django_openid/consumer.py", line 383, in process_request
     if self.session_key in request.session:
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/contrib/sessions/backends/base.py", line 43, in __contains__
     return key in self._session
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/contrib/sessions/backends/base.py", line 172, in _get_session
     self._session_cache = self.load()
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/contrib/sessions/backends/db.py", line 16, in load
     expire_date__gt=datetime.datetime.now()
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/manager.py", line 120, in get
     return self.get_query_set().get(*args, **kwargs)
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/query.py", line 269, in get
     num = len(clone)
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/query.py", line 68, in __len__
     self._result_cache = list(self.iterator())
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/query.py", line 207, in iterator
     for row in self.query.results_iter():
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/sql/query.py", line 262, in results_iter
     for rows in self.execute_sql(MULTI):
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/sql/query.py", line 2288, in execute_sql
     cursor = self.connection.cursor()
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/backends/__init__.py", line 81, in cursor
     cursor = self._cursor()
   File "/usr/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/backends/postgresql_psycopg2/base.py", line 98, in _cursor
     self.connection = Database.connect(**conn_params)
 OperationalError: FATAL:  Ident authentication failed for user "acacian"
注:

  • 同样的设置在runserver和dbshell下也可以正常工作
  • mod_wsgi一直在与sqlite3合作(我正处于切换点)
acacian.wsgi(有点凌乱)


谢谢大家!

我猜您的问题在于数据库连接设置(settings.py)。我假设您已经创建了数据库和syncdb'd等

本文在Ubuntu 8.10上设置Django/Postgres/etc非常棒(我已经按照它设置了几个虚拟机): 错误:

Ident authentication failed for user "acacian"
就是这个意思

当您使用runserver或dbshell时,Django进程将以您的用户ID作为进程所有者运行

当您在mod_wsgi下以守护程序模式运行Django时,它将以
WSGIDaemonProcess
指令中指定的用户身份运行。如果您在嵌入式(非守护进程)模式下运行mod_wsgi,那么userid将匹配Apache进程
User
指令


因此,您需要做的是使用
createuser
将您的用户
acacian
作为用户添加到postgresql,就像您使用自己的用户名一样。

您可能会发现这篇博文很有帮助-它试图解释“身份验证失败”错误,它的来源,你能做些什么。

这可能是你的postgres连接设置。我认为postgres默认使用unix用户ID进行身份验证,但在这种情况下,您可能希望使用标准用户名/密码身份验证(因为这是您硬编码到django设置中的内容)。因此,您可以尝试:

sudo vi /etc/postgresql/8.4/main/pg_hba.conf
(或emacs或nano等)。然后更改以下行:

local   all         all                               ident
致:

local   all         all                               ident
local   all         all                               password