nginx启动报错 error while loading shared libraries: libfdfsclient.so: cannot open shared object file: No such file or directory

介绍


乍看这个报错就是缺失库文件

nginx命令启动报错


error while loading shared libraries: libfdfsclient.so: 
cannot open shared object file: No such file or directory

查看nginx使用的库


从错误提示信息可以得知是因为缺少lib文件导致,$ ldd $(which /usr/local/nginx/sbin/nginx)进一步查看具体内容:

ldd /data/fastdfsnginx/sbin/nginx 
linux-vdso.so.1 =>  (0x00007fffb55c6000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fca5318b000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fca52f6f000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fca52d38000)
libfastcommon.so => /lib64/libfastcommon.so (0x00007fca52aeb000)
libfdfsclient.so => not found
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fca52889000)
libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007fca52426000)
libz.so.1 => /lib64/libz.so.1 (0x00007fca52210000)
libc.so.6 => /lib64/libc.so.6 (0x00007fca51e42000)
/lib64/ld-linux-x86-64.so.2 (0x00007fca5338f000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007fca51c3f000)
libm.so.6 => /lib64/libm.so.6 (0x00007fca5193d000)

可以看到 libfdfsclient.so => not found

解决方法


像这样的问题,有以下 3 种原因:

  • 未安装 fdfsclient
  • libfdfsclient.so 名字不对
  • 未设置 LD_LIBRARY_PATH

我这里可以确定 fastdfsclient 已经安装

如果是文件名字不对,只需要把库名做个软链接就可以了

设置 LD_LIBRARY_PATH


export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH

查看ldd /data/fastdfsnginx/sbin/nginx


linux-vdso.so.1 =>  (0x00007ffc3e1fc000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f4a8d48a000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4a8d26e000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f4a8d037000)
libfastcommon.so => /usr/lib/libfastcommon.so (0x00007f4a8cdea000)
libfdfsclient.so => /usr/lib/libfdfsclient.so (0x00007f4a8cbd0000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f4a8c96e000)
libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f4a8c50b000)
libz.so.1 => /lib64/libz.so.1 (0x00007f4a8c2f5000)
libc.so.6 => /lib64/libc.so.6 (0x00007f4a8bf27000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4a8d68e000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007f4a8bd24000)
libm.so.6 => /lib64/libm.so.6 (0x00007f4a8ba22000)

再次测试启动nginx


/data/fastdfsnginx/sbin/nginx -c /data/fastdfsnginx/conf/nginx.conf -t
ngx_http_fastdfs_set pid=25946
nginx: the configuration file /data/fastdfsnginx/conf/nginx.conf syntax is ok

版权声明:本文为作者原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原创文章,作者:老C,如若转载,请注明出处:https://www.code404.icu/1459.html

发表评论

登录后才能评论