Articles

How to compile NGINX with external OpenSSL libraries and custom linker options


NGINX does not pick up LDFLAGS

We are all used to the environment variables like CFLAGS, LDFLAGS that can be used when configuring a source tree before building it.

Thing is, Nginx does this a bit different, so if you try to build it and link it against an OpenSSL installation that is not in the standard paths (like /usr/lib, /usr/local/lib, etc) by setting LDFLAGS to your OpenSSL installation, you will fail miserably.

Passing LDFLAGS or custom linker arguments when configuring Nginx

Nginx has a special option in its configure script, which is --with-ld-opt, and you can use it like this to pass the right linker options for your OpenSSL installation:

And that will allow you to link nginx to your custom OpenSSL installation. Enjoy!