bugzilla无法连接到postgres服务器

时间:2014-01-19 17:48:42

标签: postgresql email bugzilla

我刚刚在Scientific Linux的6.4版本上安装了bugzilla-4.4.1,而且我在连接数据库时遇到了问题(Pg版本8.4)。

当我尝试获取主页面(index.cgi)时,收到以下消息:

软件错误:

Can't connect to the database.
Error: could not connect to server: Permission denied
    Is the server running on host "127.0.0.1" and accepting
    TCP/IP connections on port 5432?
  Is your database installed and up and running?
  Do you have the correct username and password selected in localconfig?

For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.

Postgres的pg_hba.conf.conf已在localhost上配置为md5 auth:

host all all 127.0.0.1/32 md5

我可以使用psql连接到数据库中的错误用户:

psql -h 127.0.0.1 -U bugs

运行checksetup.pl似乎确认数据库已正确设置和配置:

...剪辑...

Reading ./localconfig...
Checking for               DBD-Pg (v2.7.0)    ok: found v2.15.1 
Checking for           PostgreSQL (v8.03.0000) ok: found v08.04.1800 

Removing existing compiled templates...
Precompiling templates...done.
Fixing file permissions...

Now that you have installed Bugzilla, you should visit the 'Parameters'
page (linked in the footer of the Administrator account) to ensure it
is set up as you wish - this includes setting the 'urlbase' option to
the correct URL.
checksetup.pl complete.
[root@PAHRALBLNX001 bugzilla]# 

并且testserver.pl脚本表示服务器已正确设置:

[root@PAHRALBLNX001 bugzilla]# ./testserver.pl http://127.0.0.1/
TEST-OK Webserver is running under group id in $webservergroup.
TEST-OK Got padlock picture.
TEST-OK Webserver is executing CGIs via mod_cgi.
TEST-OK Webserver is preventing fetch of http://127.0.0.1/localconfig.

我还验证了localconfig中的bug用户名和密码与Postgres中的设置匹配。

但有一点似乎很奇怪,当我使用Wireshark查看localhost时,我在访问bugzilla主页时没有看到任何连接到PostgreSQL服务器的尝试。但是,如果我使用psql连接到PostgreSQL服务器,我确实在Wireshark中看到了连接。

修改

我还发现bugzilla不会发送电子邮件。正如DanielVérité所指出的那样,这是一个selinux问题。我将httpd_can_sendmail和httpd_can_network_connect更改为true,现在它可以正常工作。

1 个答案:

答案 0 :(得分:4)

根据错误消息:

  

错误:无法连接到服务器:权限被拒绝
      服务器是否在主机“127.0.0.1”上运行并接受       端口5432上的TCP / IP连接?

尝试连接到IP地址时,

权限被拒绝意味着它被本地安全策略拒绝。 必须启用Web服务器才能使用以下命令连接到数据库:

setsebool -P httpd_can_network_connect_db 1

如果还不够:

setsebool -P httpd_can_network_connect 1

有关详情,请参阅http://wiki.centos.org/TipsAndTricks/SelinuxBooleans