Nginx启动错误:error while loading shared libraries: libpcre.so.1

Posted 穆晟铭

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx启动错误:error while loading shared libraries: libpcre.so.1相关的知识,希望对你有一定的参考价值。

# /usr/local/nginx/sbin/nginx

/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

  

从错误提示信息可以得知是因为缺少lib文件导致,进一步查看具体内容:

# ldd $(which /usr/local/nginx/sbin/nginx)

libpthread.so.0 => /lib64/libpthread.so.0 (0x00000030e8400000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00000030f9a00000)
libpcre.so.1 => not found
libluajit-5.1.so.2 => not found
libcrypto.so.6 => /lib64/libcrypto.so.6 (0x00000030f2a00000) 
libz.so.1 => /lib64/libz.so.1 (0x00000030e8800000) 
libc.so.6 => /lib64/libc.so.6 (0x00000030e7800000) 
/lib64/ld-linux-x86-64.so.2 (0x00000030e7400000) 
libdl.so.2 => /lib64/libdl.so.2 (0x00000030e8000000)

  

一:libpcre.so.1 => not found

比如上面的是 /lib64/*,这个和下面解决问题时创建的软连接有关系

解决办法:

1、首先确认已经安装好pcre 软件(nginx 依赖该软件)

2、创建软连接

对于/lib/* 32位系统来说:查看结果显示 : libpcre.so.1 => not found ,同时注意lib库的路径,有/lib/* 和 /lib64/* 之分。

#查看lib库
#  ls /lib/ |grep pcre
libpcre.so.0
libpcre.so.0.0.1

#添加软连接
# ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1

  

ps: 也有可能 pcre lib文件在目录:/usr/local/lib/

对于/lib64/* 64位系统来说:

	#查看lib库
#  ls /lib64/ |grep pcre
libpcre.so.0
libpcre.so.0.0.1

#添加软连接
# ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1

  

 

 

 

二:libluajit-5.1.so.2 => not found

查找libluajit-5.1.so.2

find / -iname libluajit-5.1.so.2

 

实际上现实是:

/usr/local/lib/libluajit-5.1.so.2
/usr/local/lib/libluajit-5.1.so.2.0.5

  

 

解决办法

因为安装在缺省路径,所以LuaJIT对应的lib,include均在/usr/local目录里,但nginx默认查找/usr/lib和/usr/include/lib,做以下操作即可
#ln -s /usr/local/lib/libluajit-5.1.so.2 /usr/lib/libluajit-5.1.so.2
#ln -s /usr/local/lib/libluajit-5.1.so.2.0.2 /usr/lib/libluajit-5.1.so.2.0.2

  

 

  

 



以上是关于Nginx启动错误:error while loading shared libraries: libpcre.so.1的主要内容,如果未能解决你的问题,请参考以下文章

解决软件启动报error while loading shared libraries: libgd.so.2: cannot open shared object错误

nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No

nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No

Nginx 启动报错 (nginx: error while loading shared libraries: XXX: cannot open shared object file: No suc

nginx error: upstream prematurely closed connection while reading response header from upstream(示例代码

在windows上启动nginx 出现了错误