简体   繁体   English

数据库连接错误:Centos 6 / Apache 2.4 / Postgres 9.4 / Django 1.9 / mod_wsgi 3.5 / python 2.7

[英]Database Connect Error: Centos 6 / Apache 2.4 / Postgres 9.4 / Django 1.9 / mod_wsgi 3.5 / python 2.7

I am trying to get my website up and running. 我正在尝试使我的网站正常运行。 Everything seems to work fine, but when I go to a page with a database write - I get this: 一切似乎都可以正常工作,但是当我进入数据库写页面时,我得到了:

[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

This line shows that a user "leechprotest" cannot connect: 此行显示用户“ leechprotest”无法连接:

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

However I don't have a user called leechprotect. 但是我没有一个名为leechprotect的用户。 leechportect is a default user on MySQL (im guessing), because MySQL is installed as the default database on my dedicated server. leechportect是MySQL的默认用户(我猜是这样),因为MySQL是作为我的专用服务器上的默认数据库安装的。

My Django settings.py file: 我的Django settings.py文件:

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

I already know my database and entire site works on my test server at home. 我已经知道我的数据库和整个站点都可以在家里的测试服务器上运行。 I think it might be interference with MySQL and PostgreSQL. 我认为这可能会干扰MySQL和PostgreSQL。

Any help much appreciated. 任何帮助,不胜感激。

EDIT (After disabling leech protection): 编辑(禁用水ech保护后):

[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

EDIT 2: 编辑2:

I found that Apache comes preconfigured on cPanel with a rewrite function: 我发现Apache在cPanel上预先配置了重写功能:

These lines are in the httpd.conf file: 这些行在httpd.conf文件中:

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

I tried to comment out these lines, but cPanel just regenerates the default file. 我试图注释掉这些行,但是cPanel只是重新生成了默认文件。 I looked how to edit and I found: 我看了看如何编辑,发现:

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

From what I see, anyting written outside the <VirtualHost></VirtualHost> tag with be permanently saved when running the above command. 据我所知,运行上述命令时,在<VirtualHost></VirtualHost>标记之外编写的任何内容都将被永久保存。

this got rid of the Database error problem. 这摆脱了数据库错误的问题。 But I still get a 500 server error. 但是我仍然收到500个服务器错误。 And all other error log messages are the same. 并且所有其他错误日志消息都是相同的。

MySQL and PostgreSQL both do not come along with a user called 'leechprotect'. MySQL和PostgreSQL都没有附带“ leechprotect”用户。 But a google search points out, that this username is related to cPanel - might be worth reading that to understand whats going on. 但谷歌搜索指出,该用户名与cPanel有关 -可能值得一读以了解发生了什么。 Afterwards you might consider deactivating it for you project directory. 之后,您可以考虑为您的项目目录停用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM