Unable to load dynamic library ‘swoole.so’ (tried: /usr/local/php/lib/php/extensions/no-debug-non-zt

Gracefully shutting down php-fpm … done
Starting php-fpm [28-Nov-2018 12:01:21] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library ‘swoole.so’ (tried: /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/swoole.so (libnghttp2.so.14: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/swoole.so.so (/usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/swoole.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
done

问题分析

出现这个问题是因为swoole使用libnghttp2这个库时没有找到,但是如果你确实安装了那就按照我以下的方式处理。
在swoole中这个问题往往出现在刚开始加了http2编译选项时报错找不到nghttp2库然后手动安装了nghttp2后的问题,如下:

#error “Enable http2 support, require nghttp2 library.” #error “Enable http2 support, require nghttp2 library.”

如果出现以上问题很明显没有nghttp2库那就按照以下方式安装

wget https://github.com/nghttp2/nghttp2/releases/download/v1.34.0/nghttp2-1.34.0.tar.gz
tar -zxvf nghttp2-1.30.0.tar.bz2
cd nghttp2-1.30.0
./configure
make
make install

如果没有报错那就成功了。
然后

pecl install swoole

就可以安装swoole扩展了
但是等你重启php-fpm时问题就出现了

Gracefully shutting down php-fpm … done
Starting php-fpm [28-Nov-2018 12:01:21] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library ‘swoole.so’ (tried: /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/swoole.so (libnghttp2.so.14: cannot open shared object file: No such file or directory), /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/swoole.so.so (/usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/swoole.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
done

解决问题

vim /etc/ld.so.conf

在打开的文件种添加

include /usr/local/lib

Unable to load dynamic library ‘swoole.so’ (tried: /usr/local/php/lib/php/extensions/no-debug-non-zt_第1张图片

然后执行

ldconfig

这样就解决了

喜欢的话关注http://blog.csdn.net/marswill查看更多原创技术文章

讲原理

使用以上方式安装的nghttp2库在./configure种不指定–prefix时是安装到/usr/local/lib中的。而系统默认的库实在/usr/lib 和 /lib中找的。那肯定会找不到。所以需要我们手动添加到ld.so.conf中去

你可能感兴趣的:(PHP)