I encountered the following error in Nginx.
$./nginx ./nginx: error while loading shared libraries: libpcre.so.1: 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 library is not set in
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: libpcre.so.1
Nginx is looking for a file
libpcre.so.1 which comes under the PCRE library and usually installed on UNIX.
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 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
libpcre.so.1 is available under /usr/local/lib
Start Nginx, it should be right now.
Interested in learning Nginx? Check out this course.
More great readings on Nginx
How to Redirect AMP Page to Non-AMP in Nginx, Apache, Cloudflare?Abhishek Nair on September 27, 2021
How to Block .git in Apache, Nginx and Cloudflare?Chandan Kumar on October 27, 2020
How to Protect Page with Password in Apache, Nginx, WordPress, Hosting?Chandan Kumar on September 11, 2020
How to Implement ZeroSSL Certificate in Apache and Nginx?Asad Ali on May 24, 2020
Configuring Nginx for Performance and SecurityMichael Aboagye on February 24, 2020
How to Enable CORS in Apache and Nginx?Chandan Kumar on October 18, 2019
Join Geekflare Newsletter
Every week we share trending articles and tools in our newsletter. More than 10,000 people enjoy reading, and you will love it too.