【プログラム実行時にライブラリファイルが見つからない】nginx:error while loading shared libraries:libpcre.so.1


【プログラム実行時にライブラリファイルが見つからない】
19 Oct 2013 
Written by  Chandan Kumar 

Published in Nginx 
DISQUS_COMMENTS 
Tweet
inShare
Share on Thumblr
name="fb_xdm_frame_http"frameborder="0"allowtransparency="true"scrolling="no"id="fb_xdm_frame_http"aria-hidden="true"title="Facebook Cross Domain Communication Frame"tabindex="-1"src="http://static.ak.facebook.com/connect/xd_arbiter/7r8gQb8MIqE.js?version=41#channel=f2d5f2c37&origin=http%3A%2F%2Fchandank.com"style="max-width: 100%; border-style: none;"> name="fb_xdm_frame_https"frameborder="0"allowtransparency="true"scrolling="no"id="fb_xdm_frame_https"aria-hidden="true"title="Facebook Cross Domain Communication Frame"tabindex="-1"src="https://s-static.ak.facebook.com/connect/xd_arbiter/7r8gQb8MIqE.js?version=41#channel=f2d5f2c37&origin=http%3A%2F%2Fchandank.com"style="max-width: 100%; border-style: none;">
name="f3235b17c4"width="90px"height="1000px"frameborder="0"allowtransparency="true"scrolling="no"title="fb:like Facebook Social Plugin"src="http://www.facebook.com/plugins/like.php?action=like&app_id=&channel=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter%2F7r8gQb8MIqE.js%3Fversion%3D41%23cb%3Df3945eab98%26domain%3Dchandank.com%26origin%3Dhttp%253A%252F%252Fchandank.com%252Ff2d5f2c37%26relation%3Dparent.parent&color_scheme=light&href=http%3A%2F%2Fchandank.com%2Fwebservers%2Fnginx%2Fnginx-error-while-loading-shared-libraries-libpcre-so-1&layout=standard&locale=en_US&sdk=joey&send=true&show_faces=false&width=90"style="max-width: 100%; position: absolute; border-style: none; visibility: visible; width: 0px; height: 0px;">
【解決策: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=::~(現在のユーザーホーム):.:~soft 01(soft 01ユーザーホーム)]]

$./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.