I'm trying to install nginx and no matter what I do, nginx can't seem to find my openssl path. It looks like it's searching for files that don't exist in any of the openssl directories. Below is my make output. I've tried to specify various paths for nginx to look in for openssl.

[root@server nginx-0.8.54]# make
make -f objs/Makefile
make[1]: Entering directory `/root/nginx-0.8.54'
cd /usr/local/ssl \
        && make clean \
        && ./config --prefix=/usr/local/ssl/.openssl no-shared  no-threads \
        && make \
        && make install LIBDIR=lib
make[2]: Entering directory `/usr/local/ssl'
make[2]: *** No rule to make target `clean'.  Stop.
make[2]: Leaving directory `/usr/local/ssl'
make[1]: *** [/usr/local/ssl/.openssl/include/openssl/ssl.h] Error 2
make[1]: Leaving directory `/root/nginx-0.8.54'
make: *** [build] Error 2

Anyone have any thoughts on this?

9 Answers 9


This can also occur when your nginx configure uses relative paths. It finds the libraries much more reliably if full paths from / are used instead.

Doesn't work: ./configure --with-openssl=../openssl-source

Works: ./configure --with-openssl=/home/build/src/openssl-source

  • 1
    Great, worked for me. I was using ~/src/openssl-1.0.1 and it was failing. Using /home/me/src/openssl-1.0.1 fixed it.
    – jaygooby
    Jun 27, 2014 at 10:44
./configure —with-cc-opt="-I/usr/local/opt/openssl/include" --with-ld-opt="-L/usr/local/opt/openssl/lib"
  • It is better, if you also explain, what does this command actually do. Single commands can really understable only by the people knowing them anyways. Bruce Lee.
    – peterh
    Sep 5, 2017 at 3:55
  • This points to the existing custom installation of pre-built OpenSSL. Contrary to --with-openssl, which compiles OpenSSL statically into NGINX binary. Apr 11, 2020 at 22:53

Running "yum install openssl-devel" seems lot easier than switching to ubuntu.

Had the same issue as the OP. I had openssl installed but nginx could find it when compil but the pointer to libssl-devel helped me


I can't quite recall exactly what the issue was here, but I'm assuming that a symlink to /usr/local/ssl (or openssl?) to wherever openssl actually resides would solve the issue. I haven't had any problems installing nginx with SSL support in Ubuntu 10.04 with the default OpenSSL. So I would recommend anyone struggling with this to try that out.

Also, you probably need the correct dev packages installed. Here is what I typically installing prior to install nginx..

2  apt-get update
3  apt-get install gcc
4  apt-get install g++
5  wget http://www.python.org/ftp/python/2.7/Python-2.7.tgz
6  wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz
7  wget http://zlib.net/zlib-1.2.5.tar.gz
8  ls
9  gzip -d pcre-8.12.tar.gz 
10  gzip -d zlib-1.2.5.tar.gz 
11  gzip -d Python-2.7.tgz 
12  tar -xvf zlib-1.2.5.tar 
13  cd zlib-1.2.5
14  ./configure 
15  make
16  ls
17  Makefile
18  ls
19  ./configure 
20  make
21  sudo apt-get install build-essential
22  make
23  make install
24  cd ..
25  ls
26  tar -xvf pcre-8.12.tar 
27  cd pcre-8.12
28  ./configure --prefix=/usr --enable-unicode-properties
29  make
30  make install
31  cd ..
32  ls
33  tar -xvf Python-2.7.tar 
34  apt-get install openssl
35  cd Python-2.7
36  apt-get install libssl-dev
37  apt-get install libperl-dev
38  ./configure --help
39  ./configure --enable-ipv6
40  make
41  make install

If you are trying to build nginx with macOS and openssl is installed via brew, the openssl library is installed under path like: /usr/local/opt/openssl. From brew info openssl

This formula is keg-only, which means it was not symlinked into /usr/local,

because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

In case like this, as @Bingnan said, you can let the configure script know the include and lib paths of openssl via --with-cc-opt and --with-ld-opt:

./configure --with-cc-opt="-I/usr/local/opt/openssl/include" --with-ld-opt="-L/usr/local/opt/openssl/lib"


openssl headers are usually provided by libssl-dev on Ubuntu. There's also a --with-openssl=DIR ./configure option for nginx that lets you manually specify the path to openssl sources. Any reason why you're building it from source instead of using your package manager?

  • 1
    package managers aren't the latest versions. I'd rather upgrade everything myself. I'm running on CentOS 5.5 though. I'm using the --with-openssl=DIR option, but it's looking for files in my openssl path that don't exist.
    – Chris
    Mar 11, 2011 at 2:03
  • 2
    You'll need libssl-devel on CentOS.
    – mech-hisui
    Mar 11, 2011 at 2:04
  • The package is named differently than that on CentOS.. I ended up switching to Ubuntu and got everything working. Thanks for the help though.
    – Chris
    Mar 13, 2011 at 8:25
  • 1
    In current Ubuntu the command is ./configure --with-openssl=/usr/include/openssl/
    – Nathan V
    Sep 21, 2015 at 19:48

For Zlib

untar the zlib tar file and then configure it

Path - /opt/app/workload/nginx-test/nginx-1.8.0/zlib/zlib-1.2.8

./configure --prefix=/opt/app/workload/nginx-test/nginx-1.8.0/zlib/zlib-1.2.8
make install


Untar PCRE file then configure it

Path - /opt/app/workload/nginx-test/nginx-1.8.0/pcre/pcre-8.36

./configure --prefix=/opt/app/workload/nginx-test/nginx-1.8.0/pcre/pcre-8.36

make install

Just untar the file no need to configure it, Nginx will use it by it self

for openssl

Path - /opt/app/workload/nginx-test/nginx-1.8.0/openssl-1.0.1l

For Nginx

./configure --prefix=/opt/app/workload/nginx-test/nginx-1.8.0/nginx --with-pcre=/opt/app/workload/nginx-test/nginx-1.8.0/pcre/pcre-8.36 --with-zlib=/opt/app/workload/nginx-test/nginx-1.8.0/zlib/zlib-1.2.8 --with-http_ssl_module --with-openssl=/opt/app/workload/nginx-test/nginx-1.8.0/openssl-1.0.1l

--with-openssl=path sets the path to the OpenSSL library sources.

the path is openssl source,not make install dir

mac:nginx-1.17.3 qidizi$ ls ../openssl-OpenSSL_1_1_1c/.
./        ../       .cfg.sh   .openssl/ 

pcre or zlib is the same;


In my case the problem was that I tried to pass --prefix and --openssldir to nginx --with-openssl-opt option:

RUN ./configure --prefix=/usr/local/nginx \
                --sbin-path=/usr/local/nginx/nginx \
                --conf-path=/usr/local/nginx/nginx.conf \
                --pid-path=/run/nginx.pid \
                --with-openssl=/usr/local/src/openssl-1.1.1c \
                --with-openssl-opt="--prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers" \
                --with-http_ssl_module \
                --with-stream \

Nginx expects built openssl to reside in .openssl subfolder of openssl sources folder, in my case /usr/local/src/openssl-1.1.1c/.openssl. But I passed it a prefix and openssldir, so built openssl resided in system location of /usr/local/ssl.

So nginx couldn't find neither openssl headers upon preprocessing (objs/Makefile was looking for them in /usr/local/src/openssl-1.1.1c/.openssl/include), nor libssl.a/libcrypto.a later on upon linkage (objs/Makefile expected them in /usr/local/src/openssl-1.1.1c/.openssl/lib).

I just removed prefix and openssldir options and build worked for me:

RUN ./configure --prefix=/usr/local/nginx \
                --sbin-path=/usr/local/nginx/nginx \
                --conf-path=/usr/local/nginx/nginx.conf \
                --pid-path=/run/nginx.pid \
                --with-openssl=/usr/local/src/openssl-1.1.1c \
                --with-openssl-opt="shared zlib enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers" \
                --with-http_ssl_module \
                --with-stream \

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .