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

Posted reblue520

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php7.2安装pgsql和pdo_pgsql报错/usr/lib64/libldap_r-2.4.so.2: undefined symbol: ber_sockbuf_io_udp的处理...相关的知识,希望对你有一定的参考价值。

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

以上是关于php7.2安装pgsql和pdo_pgsql报错/usr/lib64/libldap_r-2.4.so.2: undefined symbol: ber_sockbuf_io_udp的处理...的主要内容,如果未能解决你的问题,请参考以下文章

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

PHP下添加pdo_pgsql扩展

Php7安装pdo_pgsql,pgsql扩展

安装PHP扩展

Php7安装pdo_pgsql,pgsql扩展

Linux 安装PHP扩展过程