Roundcube無法連線到PostgreSQL資料庫

Roundcube無法連線到PostgreSQL資料庫

我正在嘗試在 CentOS 5.5 伺服器上安裝 Roundcube,並使用 PostgreSQL 8.1.22 資料庫。

安裝程式腳本的第一頁檢查 php 庫等是否存在,給了我全面的綠色 OK。我什至不遺餘力地安裝了可選的。

第二頁產生了兩個設定檔(main.inc.php 和 db.inc.php),我將其放置到位。

第三頁是出了問題的地方:

檢查資料庫設定 DSN(寫入):不正常(MDB2 錯誤:連線失敗)

確保配置的資料庫存在並且使用者有寫入權限

DSN: pgsql://roundcube:password@localhost/roundcubemail

您在那裡看到的資訊(使用者 roundcube、密碼、伺服器本機主機和資料庫 roundcubemail)都是正確的。資料庫roundcubemail屬於使用者roundcube,且具有寫入權限。

我不知道為什麼它無法連接到該資料庫。我使用 phpPgAdmin 來管理它,它在同一台伺服器上的同一個 Apache 上運行!

更新
更多資訊:我的 postgres 日誌檔案有很多這些:
FATAL: no pg_hba.conf entry for host "127.0.0.1", user "roundcube", database "roundcubemail", SSL off
但是,我的 pg_hba.conf 檔案有:
# "local" is for Unix domain socket connections only
local all all trust
host all all 127.0.0.1/32 trust

使用 telnet 連接到連接埠 5432 上的 localhost 和 127.0.0.1 運作正常。

答案1

上面DerfK的答案是錯的。如果配置得當,您可以透過 Unix 套接字和 roundcube 來使用 PostgreSQL。在 db.inc.php 中,應為:

$rcmail_config['db_dsnw'] = 'pgsql://roundcube:*password*@unix(/tmp)/roundcube';

假設您已在 pgsql 中為資料庫「roundcube」建立了一個「roundcube」用戶,密碼為「密碼" 在你的主 postgresql.conf 中,你應該透過更改以下內容來防止在 IP 層上監聽:

listen_addresses = ''
unix_socket_directory = '/tmp'
ssl = false  # There's no point in using SSL on a local UNIX socket except wasting CPU

另外,這是最重要的部分,您必須更改 pg_hba.conf 以添加以下行:

local   all         roundcube                        md5

重新啟動一切,它工作得非常好,並且比使用 TCP 連接更快(因為您避免了所有 IP 封裝)。

相關內容