<legend id='ZcO1c'><style id='ZcO1c'><dir id='ZcO1c'><q id='ZcO1c'></q></dir></style></legend>
      <tfoot id='ZcO1c'></tfoot>
    1. <small id='ZcO1c'></small><noframes id='ZcO1c'>

        <bdo id='ZcO1c'></bdo><ul id='ZcO1c'></ul>
    2. <i id='ZcO1c'><tr id='ZcO1c'><dt id='ZcO1c'><q id='ZcO1c'><span id='ZcO1c'><b id='ZcO1c'><form id='ZcO1c'><ins id='ZcO1c'></ins><ul id='ZcO1c'></ul><sub id='ZcO1c'></sub></form><legend id='ZcO1c'></legend><bdo id='ZcO1c'><pre id='ZcO1c'><center id='ZcO1c'></center></pre></bdo></b><th id='ZcO1c'></th></span></q></dt></tr></i><div id='ZcO1c'><tfoot id='ZcO1c'></tfoot><dl id='ZcO1c'><fieldset id='ZcO1c'></fieldset></dl></div>

      1. PHP 无法在 CentOS 7 上连接到 PostgreSQL

        PHP can#39;t connect to PostgreSQL on CentOS 7(PHP 无法在 CentOS 7 上连接到 PostgreSQL)
        <i id='tMK9y'><tr id='tMK9y'><dt id='tMK9y'><q id='tMK9y'><span id='tMK9y'><b id='tMK9y'><form id='tMK9y'><ins id='tMK9y'></ins><ul id='tMK9y'></ul><sub id='tMK9y'></sub></form><legend id='tMK9y'></legend><bdo id='tMK9y'><pre id='tMK9y'><center id='tMK9y'></center></pre></bdo></b><th id='tMK9y'></th></span></q></dt></tr></i><div id='tMK9y'><tfoot id='tMK9y'></tfoot><dl id='tMK9y'><fieldset id='tMK9y'></fieldset></dl></div>

        <small id='tMK9y'></small><noframes id='tMK9y'>

              1. <tfoot id='tMK9y'></tfoot>
                  <tbody id='tMK9y'></tbody>
              2. <legend id='tMK9y'><style id='tMK9y'><dir id='tMK9y'><q id='tMK9y'></q></dir></style></legend>
                  <bdo id='tMK9y'></bdo><ul id='tMK9y'></ul>

                  本文介绍了PHP 无法在 CentOS 7 上连接到 PostgreSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 OSX 上的 VirtualBox 中运行 CentOS 7.Apache、PHP 5.4 和 PostgreSQL 9.2 都在运行.但是,当我的(简单)php 脚本尝试连接到 PostgreSQL 时,它不起作用:

                  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:

                  警告:pg_connect():无法连接到 PostgreSQL 服务器:可以未连接到服务器:权限被拒绝服务器是否在主机上运行127.0.0.1"并接受端口 5432 上的 TCP/IP 连接?在/var/www/html/pg.php 在第 7 行

                  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 正在运行
                  • PHP 很好,phpinfo() 告诉我 PostgreSQL 函数可用
                  • PostgreSQL 9.2 正在运行
                  • psql 可以使用 localhost 或 127.0.0.1 以及 192.168.178.111 连接到数据库
                  • 我 Mac 上的 pgAdmin 可以使用 ip 地址 192.168.178.111 连接到这个数据库
                  • iptables 已关闭
                  • pg_hba.conf 已更改为接受所有没有任何密码的连接(愚蠢,我知道):

                  托管所有所有 0.0.0.0/0 信任

                  host all all 0.0.0.0/0 trust

                  但是php连接不上....这是我的脚本:

                  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');
                  ?>
                  

                  内部连接工作(psql),外部连接也工作(我的笔记本电脑上的pgAdmin),但是php连接不起作用......

                  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?

                  推荐答案

                  可能 SELinux 阻塞了你的数据库连接.

                  Probably SELinux is blocking your database connection.

                  确保您设置了正确的布尔值以允许您的 Web 应用程序与数据库通信:

                  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
                  

                  这篇关于PHP 无法在 CentOS 7 上连接到 PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <i id='4U8CI'><tr id='4U8CI'><dt id='4U8CI'><q id='4U8CI'><span id='4U8CI'><b id='4U8CI'><form id='4U8CI'><ins id='4U8CI'></ins><ul id='4U8CI'></ul><sub id='4U8CI'></sub></form><legend id='4U8CI'></legend><bdo id='4U8CI'><pre id='4U8CI'><center id='4U8CI'></center></pre></bdo></b><th id='4U8CI'></th></span></q></dt></tr></i><div id='4U8CI'><tfoot id='4U8CI'></tfoot><dl id='4U8CI'><fieldset id='4U8CI'></fieldset></dl></div>
                  • <bdo id='4U8CI'></bdo><ul id='4U8CI'></ul>
                        <tbody id='4U8CI'></tbody>

                    • <small id='4U8CI'></small><noframes id='4U8CI'>

                      <legend id='4U8CI'><style id='4U8CI'><dir id='4U8CI'><q id='4U8CI'></q></dir></style></legend>

                          • <tfoot id='4U8CI'></tfoot>