次のエラーが出ています。
ローカルホストにてエラーです。
当方何分初心者ですので四苦八苦しています。
発生している問題・エラーメッセージ
Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Permission denied Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? in /var/www/html/index.php on line 5 database not found
/var/lib/pgsql/data/pg_hba.confを設定しかえればいいと思うのですが
当方初心者でどう変更したら良いかわかりません。
##該当のソースコード
<?php ini_set('display_errors',1); ini_set('error_reporting',E_ALL); $conn = pg_connect("host=localhost port=5432 dbname=testdb user=sasaki password=password"); if (!$conn) { echo "database not found\n"; exit; } $result = pg_query($conn, "select no,name from test"); if (!$result) { echo "table not found\n"; exit; } while ($row=pg_fetch_row($result)) { echo "No: $row[0] name:$row[1]"; echo "\n"; } ?>
##試したこと
データベース、PHPは起動は確認済み(php_infoも出ます。)で
該当するデータベースおよびテーブル、ユーザー、パスワードは作成済みです。
psqlにてデータベースにアクセスしselect no,name from testを入力した場合は
値が返ってきます。
pg_hba.confにて以下の項目を変更しています。
host all all 127.0.0.1/32 ident → trust
##補足情報(FW/ツールのバージョンなど)
centOS7
POstgresql9.2.23
Apache2.4.6
PHP5.4.16