$./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 compiled & 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 come 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 the 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.

Did it help you?

Reader Interactions

Comments

Comments

Your email address will not be published. Required fields are marked *