php-fpm启动提示error while loading shared libraries: libmysqlclient.so.16解决

朋友的一台跑lnmp的Cent OS出现了故障,本来服务器使用的是编译版本的mysql,但是朋友却阴差阳错的又用yum装了一个,安装后发现有问题,于是再次卸载,卸载后重新编译安装mysql,发现php-fpm无法启动了,提示以下内容

Starting php_fpm /usr/local/php/bin/php-cgi: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory

首先检查/etc/ld.so.conf,里面自定义了mysql库目录为/usr/local/mysql/lib/mysql/

检查该目录,发现文件都在,再用ldconfig命令来检查库文件的加载情况

ldconfig 

ldconfig: /usr/local/mysql/lib/mysql/libmysqlclient_r.so.16 is not a symbolic link

ldconfig: /usr/local/mysql/lib/mysql/libmysqlclient.so.16 is not a symbolic link 

提示两个so文件不是符号链接,这时再用ldconfig -v来查看两个文件链接的目标

ldconfig -v 

/usr/local/mysql/lib/mysql:
ldconfig: /usr/local/mysql/lib/mysql/libmysqlclient_r.so.16 is not a symbolic link

    libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
ldconfig: /usr/local/mysql/lib/mysql/libmysqlclient.so.16 is not a symbolic link

    libmysqlclient.so.16 -> libmysqlclient.so.16.0.0

弄清楚链接的目标之后,重新制作符号链接

ln -s libmysqlclient_r.so.16 libmysqlclient_r.so.16.0.0 

ls -s libmysqlclient.so.16 libmysqlclient.so.16.0.0 

再次启动php-fpm,问题解决

点赞