php7.2安装pgsql和pdo_pgsql报错/usr/lib64/libldap_r-2.4.so.2: undefined symbol: ber_sockbuf_io_udp的处理...

博客内容讲述了在安装PHP7.2过程中遇到pgsql和pdo_pgsql扩展与ldap扩展冲突的问题,通过重新编译PHP并禁用ldap扩展,然后单独安装pgsql和pdo_pgsql,以及处理ldap依赖问题,最终成功解决报错。

php7.2安装报错pgsql和pdo_pgsql报错/usr/lib64/libldap_r-2.4.so.2: undefined symbol: ber_sockbuf_io_udp
报错如下:
[05-Aug-2021 06:55:39 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_pgsql.so' (tried: /usr/local/php-7.2.24_fpm/lib/php/extensions/no-debug-non-zts-20170718/pdo_pgsql.so (/usr/lib64/libldap_r-2.4.so.2: undefined symbol: ber_sockbuf_io_udp), /usr/local/php-7.2.24_fpm/lib/php/extensions/no-debug-non-zts-20170718/pdo_pgsql.so.so (/usr/local/php-7.2.24_fpm/lib/php/extensions/no-debug-non-zts-20170718/pdo_pgsql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
用了很久找不出问题,猜想是pgsql和安装的ldap扩展冲突
# 和pgsql冲突的 php 编译参数

./configure  --prefix=/usr/local/php-7.2.24_fpm --with-config-file-path=/usr/local/php-7.2.24_fpm/etc --with-openssl=/usr/local/lab/openssl-1.0.2p --with-libxml-dir=/usr --with-zlib-dir=/usr/local/lab/zlib-1.2.11 --with-bz2 --enable-calendar --with-curl=/usr/local/lab/curl-7.36.0 --enable-dba --enable-exif --enable-ftp --with-jpeg-dir=/usr/local/lab/jpeg-9b --with-png-dir=/usr/local/lab/libpng-1.6.10/ --with-freetype-dir=/usr/local/lab/freetype-2.5.4 --with-gd=/usr/local/lab/libgd-2.1.1 --with-gettext --enable-mbstring --with-ldap=/usr/local/openldap-2.4.23 --with-mcrypt=/usr/local/lab/libmcrypt-2.5.8_php7.2 --with-mhash=/usr/local/lab/mhash-0.9.9.9 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-unixODBC=/usr/local/lab/unixODBC-2.3.2 --with-pdo-dblib=/usr/local/lab/freetds-0.92 --enable-zip --with-iconv-dir=/usr/local/lab/libiconv-1.14 --with-fpm-user=apache --with-fpm-group=users --enable-fpm --with-xmlrpc --enable-soap --enable-mbregex --enable-opcache --enable-inline-optimization --enable-xml --enable-sockets --disable-debug --enable-pcntl --enable-shmop

于是去掉 --with-ldap=/usr/local/openldap-2.4.23 这句ldap的扩展,重新编译了php
# 为了避免干扰已有的php程序,安装到了新的目录  /usr/local/php-7.2.24_fpm_pgsql
# 重新编译参数

./configure  --prefix=/usr/local/php-7.2.24_fpm_pgsql --with-config-file-path=/usr/local/php-7.2.24_fpm_pgsql/etc --with-openssl=/usr/local/lab/openssl-1.0.2p --with-libxml-dir=/usr --with-zlib-dir=/usr/local/lab/zlib-1.2.11 --with-bz2 --enable-calendar --with-curl=/usr/local/lab/curl-7.36.0 --enable-dba --enable-exif --enable-ftp --with-jpeg-dir=/usr/local/lab/jpeg-9b --with-png-dir=/usr/local/lab/libpng-1.6.10/ --with-freetype-dir=/usr/local/lab/freetype-2.5.4 --with-gd=/usr/local/lab/libgd-2.1.1 --with-gettext --enable-mbstring --with-mcrypt=/usr/local/lab/libmcrypt-2.5.8_php7.2 --with-mhash=/usr/local/lab/mhash-0.9.9.9 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-unixODBC=/usr/local/lab/unixODBC-2.3.2 --with-pdo-dblib=/usr/local/lab/freetds-0.92 --enable-zip --with-iconv-dir=/usr/local/lab/libiconv-1.14 --with-fpm-user=apache --with-fpm-group=users --enable-fpm --with-xmlrpc --enable-soap --enable-mbregex --enable-opcache --enable-inline-optimization --enable-xml --enable-sockets --disable-debug --enable-pcntl --enable-shmop

# 安装pgsql和pdo_pgsql
# pgsql

/usr/local/src/php-7.2.24/ 为源码目录

cd /usr/local/src/php-7.2.24/ext/pgsql
/usr/local/php-7.2.24_fpm_pgsql/bin/phpize
./configure --with-php-config=/usr/local/php-7.2.24_fpm_pgsql/bin/php-config
make && make install

# pdo_pgsql

cd /usr/local/src/php-7.2.24/ext/pdo_pgsql
/usr/local/php-7.2.24_fpm_pgsql/bin/phpize
./configure --with-php-config=/usr/local/php-7.2.24_fpm_pgsql/bin/php-config
make && make install

# 使用php自带的扩展安装ldap插件

yum install openldap openldap-devel -y

ln -sv  /usr/lib64/libldap* /usr/lib/ 
cd /usr/local/src/php-7.2.24/ext/ldap
/usr/local/php-7.2.24_fpm_pgsql/bin/phpize
./configure --with-php-config=/usr/local/php-7.2.24_fpm_pgsql/bin/php-config
make && make install

# 报错的处理
/usr/bin/ld: cannot find -lpng12
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
# 解决办法
yum install -y libpng12-devel
ldconfig
make clean
# make && make install

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值