25

I'm trying to compile nginx from source with the SSL module enabled. When I run this command:

./configure --with-http_ssl_module

it does its usual checks to see if everything is installed correctly, and then this pops up:

checking for OpenSSL library ... not found

./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl= option.

I know for a fact that OpenSSL is installed, because when I do openssl version I get OpenSSL 1.0.1 14 Mar 2012

So I'm pretty stumped. I thought maybe OpenSSL isn't isntalled in its default location, which is why nginx can't find it, but I have no idea where this is as it came pre-installed with the server. How can I find out where this is?

The server is running Ubuntu 12.04 LTS.

Thanks.

James Linton
  • 377
  • 2
  • 5
  • 7
  • 2
    For people using yum (CentOS | redhat | fedora) try installing openssl-devel and then try running the command. – maverick3 Feb 04 '15 at 07:24

6 Answers6

38

Most likely you're missing the libssl-dev package.

But why not save yourself all the trouble and just use a PPA for nginx?

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • What exactly are PPA's? From what I can gather people can upload packages to be installed using `apt-get`? I thought the best way to ensure I was always getting the latest version of software was to compile it from the source from the website. – James Linton Aug 11 '12 at 18:42
  • 1
    PPAs are Personal Package Archives. As you said, they are to distribute dpkg packages. Compiling from source might get you the newest version but this is not always necessary. Information for Ubuntu and the PPA can be found here: http://wiki.nginx.org/Install#Official_Debian.2FUbuntu_packages – Christopher Perrin Aug 11 '12 at 19:29
  • The info on the nginx wiki is good. It will eventually lead you to the PPA that I linked. :) – Michael Hampton Aug 11 '12 at 19:43
  • Alright thanks, I'll look into using PPA's in the future. But for this problem, installing `libssl-dev` worked. :) – James Linton Aug 11 '12 at 21:05
  • The Nginx PPA is the way to go as it provides the latest official Nginx binary through apt. Ubuntu typically provides an Nginx version a few releases back for support purposes, but using the Nginx PPA, you can get the latest release from Nginx.org. Much easier to use this approach over compiling from source & great for automated provisioning scripts. It keeps your apt on your system aware of the Nginx version currently installed making apt-based updates much easier. Unless there is a specific reason to compile from source, the PPA approach is so much easier to maintain in production. – Joe J Aug 22 '15 at 16:09
  • Why not just use a PPA: for instance, when you want old NGINX (with obsolete features) compiled from sources. Am I wrong? – sergzach Oct 03 '18 at 17:52
  • @sergzach I'm sure there's some circumstance in which you might want to run an obsolete release of nginx, but at the moment I really can't think of one. – Michael Hampton Oct 04 '18 at 18:47
  • Building from source is required if you want ngx_pagespeed or other compile time options. https://www.nginx.com/resources/wiki/start/topics/tutorials/installoptions/ – sknt May 06 '19 at 21:33
3

I used the following to get openssl for nginx:

https://ethitter.com/2016/06/nginx-openssl-1-0-2-http-2-alpn/

All other attempts either did not work, or were to clunky.

Hope this helps another...

skidadon
  • 131
  • 3
  • 2
    Helped me figure out the `--with-openssl=` flag is to point to the _source_ files. If you want to link against an already-compiled/system OpenSSL that nginx's `./configure` can't find see [this forum post](https://forum.nginx.org/read.php?2,275441,275447#msg-275447): `--with-cc-opt="-I /usr/local/include" --with-ld-opt="-L/usr/local/lib64 -ldl -Wl,-rpath,/usr/local/lib64"` (YMMV). – vesperto Oct 26 '19 at 16:48
  • Thanks for the additional reference @vesperto – skidadon Nov 01 '19 at 04:03
0

You have to specify the path were OpenSSL libraries set add it like this

PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig/" ./configure \

I found it path by searching for openssl.pc file find / -name 'openssl.pc' reference

Salem F
  • 173
  • 1
  • 10
0

In case you want to check that libssl is installed in the right place, you can type which openssl and then ldd /path/to/openssl.

0

Even when OpenSSL is already installed (brew install openssl), configure itself suggests a workaround, which worked for me:

./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master--with-openssl=~/GitHub/openssl/openssl

Pnemonic
  • 101
  • 1
  • Is the option `--with-openssl=` pointing at a cloned openssl github repo? You might consider editing your answer to reflect this as it could be confusing for people without sufficient understanding. – Jamie Lindsey Feb 09 '19 at 08:37
  • yes, /GitHub/openssl/openssl is a cloned repository of https://github.com/openssl/openssl.git – Pnemonic Feb 09 '19 at 18:35
0

If anyone still facing issue compiling nginx from source with the pcre related error, compile with "--with-pcre" attribute. And for providing pcre path, don't provide installed path. Provide pcre software path.

  1. Install pcre with

./configure

make

sudo make install

Then, provide the path of pcre source path.

./configure --prefix=/path/to/nginxToBeInstalled/mayBeInOpt/nginx-1.16.0/ --with-openssl=/path/to/installed/openssl-1.1.1b/ --with-pcre=/path/to/your/downloaded/extracted/pcre-8.42

In my case,

./configure --prefix=/opt/nginx-1.16.0/ --with-openssl=/opt/openssl-1.1.1b/ --with-pcre=/media/username/personal/Software/pcre-8.42

Thank you.

learner
  • 101
  • 2