您的位置:首页 > 运维架构 > Nginx

【程序运行时找不到库文件】nginx: error while loading shared libraries: libpcre.so.1

2014-11-29 17:56 561 查看


【程序运行时候找不到库文件】

19 Oct 2013 

Written by  Chandan Kumar 

Published in Nginx 

DISQUS_COMMENTS 

Tweet

inShare
Share on Thumblr




【解决办法:1.找下你需要的库是否存在:查找下usr/local/lib
2.如果存在这个库的话,通过设置LD_LIBRARY_PATH=/usr/local/lib: 这个环境变量,把库的路径加进去
3.重新编译程序运行看看。
原理:
系统对动态库查找规则:
/lib
/usr/lib
到环境变量LD_LIBRARY_PATH指定的路径中查找
/etc/profile 下面有显示路径 环境变量,每个目录用 : 分割  window目录分割用 ;
【1.在文件/etc/profile改  2.export LD_LIBRARY_PATH=:.:~(当前用户主目录):..:~soft01(soft01用户的主目录)】



$./nginx
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
$
If you are getting above error while starting nginx, you can fix by following.

This generally happens due to following three reasons.
You don’t have PCRE installed
Nginx was not complied & installed using pcre
PCRE library is not set in LD_LIBRARY_PATH
There are multiple ways to fix this issue. The best way I believe is using troubleshooting skills. Let’s understand the error and fix it accordingly.
nginx: error while loading shared libraries: libpcre.so.1
nginx is looking for file libpcre.so.1 which comes under PCRE library and usually installed on UNIX.

Let’s find libpcre.so.1 using find command
$find / -name libpcre.so.1
/usr/local/lib/libpcre.so.1
$

Ok, so I do have this file which means PCRE is already installed and will proceed with next troubleshooting step.
Note: If you don’t get find results then you got to install PCRE. You can either install using yum install pcre on Linux/CentOS
or can ask system administrator to install it.

Now, let’s set LD_LIBRARY_PATH as we could see libpcre.so.1 is available under /usr/local/lib
$export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH


Start nginx now, you should be able to start.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐