1

我想从 to 连接到远程数据库phppostgres但它无法连接并说

 Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server:    
could not connect to server: No route to host (0x00002751/10065) Is the server running on host "xxxxxxxxx" and accepting TCP/IP connections on port 5432? in C:\xampp\htdocs\test.php on line 4
Wrong CONN_STRING

<html> 
    <body> 
        <?php 
        $db = pg_connect('host=xxx.xxx.xxx.xxx port=5432 dbname=postgres user=postgres password=') or die('Wrong CONN_STRING'); 
        if (!$db) {
                echo 'error';
            }else{
            echo 'success';
            }

        ?> 
    </body> 

我可以从运行 apache 的同一台机器上运行的客户端访问同一个数据库pgadmin,我不明白 pgadmin 可以访问 db 但 apache webserver 的 php 无法访问?任何想法 ?

4

2 回答 2

0

这是 SELinux 的问题 以下命令修复了问题

setsebool -P httpd_can_network_connect=1

于 2011-02-24T17:45:52.507 回答
0

“没有到主机的路由”告诉您存在某种网络问题 - 不同的客户端能够从同一主机访问它的事实表明它是某种安全限制或阻止连接的防火墙,但是如果没有有关您的环境的详细信息,很难更具体。

于 2011-02-24T09:02:52.400 回答