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
Probably SELinux is blocking your database connection.
Make sure that you set the correct boolean to allow your web application to talk to the database:
sudo setsebool -P httpd_can_network_connect_db 1