PHP无法连接到PGSQL

时间:2015-07-24 23:51:20

标签: php postgresql cakephp pdo

我无法让PHP连接到PGSQL。我正在运行小牛10.9.4。以下是我遵循的步骤:

  1. 弄清楚PHP w / mac的默认生活位置(which php
  2. rmdir该目录
  3. brew install php54
  4. php -v显示新的php 5.4
  5. php -m显示没有pdo_pgsql模块
  6. brew install php54-pdo-pgsql
  7. php -m显示pdo_pgsql模块
  8. php -i显示以下信息
  9. PDO support => enabled
    PDO drivers => mysql, odbc, sqlite, pgsql
    
    pdo_mysql
    
    PDO Driver for MySQL => enabled
    Client API version => mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $
    
    Directive => Local Value => Master Value
    pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock
    
    PDO_ODBC
    
    PDO Driver for ODBC (unixODBC) => enabled
    ODBC Connection Pooling => Enabled, strict matching
    
    pdo_pgsql
    
    PDO Driver for PostgreSQL => enabled
    PostgreSQL(libpq) Version => 9.4.4
    Module version => 1.0.2
    Revision =>  $Id: 8e4cc97fb53f418d98b489c3e9d722e48446e676 $ 
    
    1. 打开/usr/local/etc/php/5.4/php.ini并添加extension=pgsql.so,然后保存
    2. sudo apachectl restart
    3. 打开phpinfo()页面
    4. PDO驱动程序部分仅显示mysql, sqlite
    5. Loaded Configuration File部分显示了php.ini与pgsql扩展名相同的文件
    6. 每当我在控制台中运行php命令时,我都会看到

      PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php54/5.4.43_2/lib/php/extensions/no-debug-non-zts-20100525/pgsql.so' - dlopen(/usr/local/Cellar/php54/5.4.43_2/lib/php/extensions/no-debug-non-zts-20100525/pgsql.so, 9): image not found in Unknown on line 0
      
      Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php54/5.4.43_2/lib/php/extensions/no-debug-non-zts-20100525/pgsql.so' - dlopen(/usr/local/Cellar/php54/5.4.43_2/lib/php/extensions/no-debug-non-zts-20100525/pgsql.so, 9): image not found in Unknown on line 0
      

0 个答案:

没有答案