I'm now developing a site on CentOS/nginx/postgresql/php(php-fpm).
And I have such a database connection code which blocks:
$dbcon = pg_connect(
"host=localhost port=5432 dbname=shex_utf8 user=webmaster password=webmaster"
);
var_dump($dbcon);
It only return false when I run that code on visiting http://example.com/dbcon.php
I haven't seen any error or warning displayed.
But if i call:
php < dbcon.php
It was returning:
resource(5) of type (pgsql link)
I changed the http server from nginx to httpd, the problem still exists.
And then I stop the php-fpm service, and run a spawn-fcgi instead, there was no problem.
What's the matter with php-fpm? How can I configure the php-fpm and work around the problem?
That was because of a selinux setting.
Worked around by:
setsebool -P httpd_can_network_connect_db 1