Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.
In Nginx Last updated: May 31, 2020
Share on:
Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.

I encountered the following error in Nginx.

./nginx: error while loading shared libraries: cannot open shared object file: No such file or directory

If you are getting the above error while starting Nginx, you can fix it by following.

This happens due to the following three reasons.

  • You don’t have PCRE installed
  • Nginx was not compiled & installed using pcre
  • PCRE library is not set in LD_LIBRARY_PATH

There are multiple ways to troubleshoot and fix this issue. Let’s understand the error and fix it accordingly.

nginx: error while loading shared libraries:

Nginx is looking for a file which comes under the PCRE library and usually installed on UNIX.

Let’s find using find command

$find / -name 

Ok, so I do have this file which means PCRE is already installed and will proceed with the next troubleshooting step.

Note: If you don’t get find results then you got to install PCRE with the below command.

yum install pcre

If you don’t have root privilege, then you may ask the system administrator to install it.

Now, let’s set LD_LIBRARY_PATH as we could see is available under /usr/local/lib

$export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Start Nginx, it should be right now.

Interested in learning Nginx? Check out this course.

  • Chandan Kumar
    As the founder of Geekflare, I’ve helped millions to excel in the digital realm. Passionate about technology, I’m on a mission to explore the world and amplify growth for professionals and businesses alike.
Thanks to our Sponsors
More great readings on Nginx
Power Your Business
Some of the tools and services to help your business grow.
  • Invicti uses the Proof-Based Scanning™ to automatically verify the identified vulnerabilities and generate actionable results within just hours.
    Try Invicti
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.
    Try Brightdata
  • is an all-in-one work OS to help you manage projects, tasks, work, sales, CRM, operations, workflows, and more.
    Try Monday
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.
    Try Intruder