- 报错信息如下:
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
根据报错的信息知道是少了一些文件,使用ldd查看程序所需要的链接动态库
linux-vdso.so.1 => (0x00007ffdf138b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe1dc5f6000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fe1dc3be000)
libpcre.so.1 => not found
libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fe1dc156000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fe1dbd11000)
libz.so.1 => /usr/local/lib/libz.so.1 (0x00007fe1dbaf5000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe1db72b000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe1dc813000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe1db527000)
根据第四行显示libpcre.so.1 => not found,同时信息显示lib的路径/lib/x86_64-linux-gnu
- 解决方法:
- 根据报错信息,查看是否安装pcre(Nginx依赖软件),如果已安装,找到安装pcre的lib所在路径。
- 创建软连接ln -s /usr/local/lib/libpcre.so.1 /lib/x86_64-linux-gnu/libpcre.so.1
- /usr/local/nginx/sbin/nginx -v查看是否安装成功。