5
編輯到PostgreSQL:我剛剛意識到這個問題可能更適合ServerFault。主持人請不要複製它,請移動它?謝謝。無法連接與PHP pg_connect()
我檢查PHP的信息,而PostgreSQL的擴展是有(pg_connect()
不是未定義)。我也能連接使用本地主機psql
到PostgreSQL(我已經適當地修改我的pg_hba.conf文件)。這裏是不工作的代碼:
<?php
$dbconn = pg_connect("host=localhost port=5432 dbname=mydb user=myuser password=mypass") or die('Could not connect: ' . pg_last_error());
?>
此代碼只是導致「無法連接:」顯示在瀏覽器中。
我檢查了我的Apache日誌,和這裏的相關錯誤信息:
PHP Warning: pg_connect() [<a href='function.pg-connect'>function.pg-connect</a>]:
Unable to connect to PostgreSQL server: could not connect to server: Permission
denied\n\tIs the server running on host "localhost" and accepting\n\tTCP/IP
connections on port 5432?
如何解決/調試呢?
編輯:我在CentOS 5.4 BTW。
謝謝,僅此而已。我只是'setenforce 0',它工作。 – ehsanul 2010-08-14 03:49:24
您還可以運行 setsebool -P httpd_can_network_connect 1 – garg 2012-05-10 14:41:10