I have CentOS 7 running in VirtualBox on OSX. Apache, PHP 5.4 and PostgreSQL 9.2 are all running. But, when my (simple) php-script tries to connect to PostgreSQL it doesn't work:
Warning: pg_connect(): Unable to connect to PostgreSQL server: 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? in /var/www/html/pg.php on line 7
- Apache is running
- PHP is fine, phpinfo() tells me PostgreSQL functions are available
- PostgreSQL 9.2 is running
- psql can connect to the database using localhost or 127.0.0.1 and also 192.168.178.111
- pgAdmin on my Mac can connect to this database using ip address 192.168.178.111
- iptables has been turned off
- pg_hba.conf has been changed to accept all connections without any password (stupid, I know):
host all all 0.0.0.0/0 trust
But php can't connect.... This is my script:
<?php ini_set('display_errors', 1); error_reporting(E_ALL); echo 'hello world!'; $conn = pg_connect('host=127.0.0.1 port=5432 user=postgres dbname=postgres'); ?>
Internal connections work (psql), external connections also work (pgAdmin on a my laptop), but the php connection doesn't work...
What is going wrong? What is it that I'm missing?