php7 安装pg_sql, pdo_pgsql扩展

  1. 找到php源码包自带的ext目录里的pgsql库
  2. 切换目录到pgsql/pdo_pgsql
  3. 找到phpize(在php安装目录下的bin文件夹下)
  4. 如下命令:
# /usr/local/php/bin/phpize 为你的phpize安装目录
/usr/local/php/bin/phpize
# /usr/local/php/bin/php-config 为你的php-config安装目录
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
  1. 配置扩展:
# /usr/local/php/etc/php.ini 为你的php.ini安装目录
extension=pgsql.so
extension=pdo_pgsql.so

中间可能会遇到configure编译报错的情况:

configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

解决方案:

yum -y install postgresql-devel