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

来源:互联网 发布:雷蒙德钱德勒 知乎 编辑:程序博客网 时间:2024/05/16 12:04

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


  • 19 Oct 2013 
  • Written by  Chandan Kumar 

  • Published in Nginx 
  • DISQUS_COMMENTS 
Tweet
Share
Share on Thumblr
Spreddit3


【解决办法: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.

  1. You don’t have PCRE installed
  2. Nginx was not complied & installed using pcre
  3. 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.
0 0
原创粉丝点击