【问题标题】:Database Connect Error: Centos 6 / Apache 2.4 / Postgres 9.4 / Django 1.9 / mod_wsgi 3.5 / python 2.7数据库连接错误:Centos 6 / Apache 2.4 / Postgres 9.4 / Django 1.9 / mod_wsgi 3.5 / python 2.7
【发布时间】:2017-03-01 12:12:15
【问题描述】:

我正在努力让我的网站启动并运行。一切似乎都运行良好,但是当我转到带有数据库写入的页面时 - 我得到了这个:

[Wed Oct 19 09:53:12.319824 2016] [mpm_prefork:notice] [pid 12411] AH00173: SIGHUP received.  Attempting to restart
[Wed Oct 19 09:53:13.001121 2016] [ssl:warn] [pid 12411] AH01909: sXXX-XXX-XXX-XXX.secureserver.net:443:0 server certificate does NOT include an ID which matches the server name
[Wed Oct 19 09:53:13.003578 2016] [mpm_prefork:notice] [pid 12411] AH00163: Apache/2.4.18 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 mod_wsgi/3.5 Python/2.7.6 configured -- resuming normal operations
[Wed Oct 19 09:53:13.003590 2016] [core:notice] [pid 12411] AH00094: Command line: '/usr/local/apache/bin/httpd'
(XID fsf92m) Database Connect Error: Access denied for user 'leechprotect'@'localhost' (using password: YES)
[Wed Oct 19 09:53:17.637487 2016] [mpm_prefork:notice] [pid 12411] AH00169: caught SIGTERM, shutting down

此行显示用户“leechprotest”无法连接:

(XID fsf92m) Database Connect Error: Access denied for user 'leechprotect'@'localhost' (using password: YES)

但是,我没有名为 leechprotect 的用户。 leechportect 是 MySQL 的默认用户(我猜),因为 MySQL 作为默认数据库安装在我的专用服务器上。

我的 Django settings.py 文件:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'prelaunch_db',
        'USER': 'postgres_user',
        'PASSWORD': 'XXXXXXXXXXXXXXX',
        'HOST': 'localhost',
        'PORT': '',
    }
}

我已经知道我的数据库和整个站点在我家的测试服务器上运行。我认为这可能是对 MySQL 和 PostgreSQL 的干扰。

非常感谢任何帮助。

编辑(禁用水蛭保护后):

[Wed Oct 19 11:40:24.000919 2016] [ssl:warn] [pid 14754] AH01909: sXXX-XXX-XXX-XXX.secureserver.net:443:0 server certificate does NOT include an ID which matches the server name
[Wed Oct 19 11:40:24.001851 2016] [suexec:notice] [pid 14754] AH01232: suEXEC mechanism enabled (wrapper: /usr/local/apache/bin/suexec)
[Wed Oct 19 11:40:24.001887 2016] [:notice] [pid 14754] ModSecurity for Apache/2.9.0 (http://www.modsecurity.org/) configured.
[Wed Oct 19 11:40:24.001892 2016] [:notice] [pid 14754] ModSecurity: APR compiled version="1.5.2"; loaded version="1.5.2"
[Wed Oct 19 11:40:24.001897 2016] [:notice] [pid 14754] ModSecurity: PCRE compiled version="8.38 "; loaded version="8.38 2015-11-23"
[Wed Oct 19 11:40:24.001900 2016] [:notice] [pid 14754] ModSecurity: LUA compiled version="Lua 5.1"
[Wed Oct 19 11:40:24.001903 2016] [:notice] [pid 14754] ModSecurity: LIBXML compiled version="2.9.2"
[Wed Oct 19 11:40:24.001905 2016] [:notice] [pid 14754] ModSecurity: Status engine is currently disabled, enable it by set SecStatusEngine to On.
[Wed Oct 19 11:40:25.001596 2016] [ssl:warn] [pid 14755] AH01909: sXXX-XXX-XXX-XXX.secureserver.net:443:0 server certificate does NOT include an ID which matches the server name
[Wed Oct 19 11:40:25.004276 2016] [mpm_prefork:notice] [pid 14755] AH00163: Apache/2.4.18 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 mod_wsgi/3.5 Python/2.7.6 configured -- resuming normal operations
[Wed Oct 19 11:40:25.004294 2016] [core:notice] [pid 14755] AH00094: Command line: '/usr/local/apache/bin/httpd -D SSL'
(XID 6jmrjj) Database Connect Error: Access denied for user 'leechprotect'@'localhost' (using password: YES)
[Wed Oct 19 11:40:31.847492 2016] [mpm_prefork:notice] [pid 14755] AH00169: caught SIGTERM, shutting down

编辑 2:

我发现 Apache 在 cPanel 上预配置了一个重写功能:

这些行在 httpd.conf 文件中:

RewriteEngine on
RewriteMap LeechProtect prg:/usr/local/cpanel/bin/leechprotect
Mutex file:/usr/local/apache/logs rewrite-map

我试图注释掉这些行,但 cPanel 只是重新生成默认文件。我查看了如何编辑并发现:

[root@sXXX-XXX-XXX-XXX]# /usr/local/cpanel/bin/apache_conf_distiller --update

据我所知,<VirtualHost></VirtualHost> 标签之外的任何内容在运行上述命令时都会被永久保存。

这摆脱了数据库错误问题。但我仍然收到 500 服务器错误。并且所有其他错误日志消息都是一样的。

【问题讨论】:

    标签: python mysql django apache postgresql


    【解决方案1】:

    MySQL 和 PostgreSQL 都没有附带名为“leechprotect”的用户。但是谷歌搜索指出,这个用户名is related to cPanel - 可能值得一读以了解发生了什么。之后您可能会考虑为您的项目目录停用它。

    【讨论】:

    • 我的错误,我在发布之前联系了我的网络托管服务提供商,他们告诉我 leechprotect 是 cPanel。另外,我在 cPanel 上禁用了它。那是行不通的。它只是在 apache error_log 中给了我很多关于安全性的警告,并带有相同的“数据库连接”错误。这只发生在数据库写入中。并且仅适用于通过 apache 请求进行的数据库写入。当我使用自定义 django 管理命令写入数据库时​​,它可以工作。
    • 我对原始帖子进行了编辑。这是禁用 leech 保护后 apache 的新错误日志
    • 也许this topic 有帮助 - 它是关于文件的所有权 - 最后没有万岁,但也许它解决了错误;)顺便说一句 - 你不能摆脱 cPanel 在全部?
    • 我喜欢 cPanel。我有一个插件可以让文件浏览和编辑变得非常容易。通过ssh做这些事情很乏味......我想我发现了问题。 cPanel 上的 Apache httpd.conf 文件预先配置了以下几行:
    • RewriteEngine on RewriteMap LeechProtect prg:/usr/local/cpanel/bin/leechprotect Mutex file:/usr/local/apache/logs rewrite-map
    猜你喜欢
    • 2017-02-26
    • 2016-06-07
    • 2011-04-07
    • 1970-01-01
    • 2011-09-24
    • 2016-05-13
    • 1970-01-01
    • 2020-04-02
    • 2016-03-31
    相关资源
    最近更新 更多