# Building nginx with non-system openssl?

**URL:** <https://www.ruby-forum.com/t/building-nginx-with-non-system-openssl/186261>\
**Category:** NGINX\
**Created:** [April 3, 2010, 5:29am UTC](https://www.ruby-forum.com/t/building-nginx-with-non-system-openssl/186261 "2010-04-03T05:29:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_DJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/73ab20/32.png) [@Ben\_DJ](https://www.ruby-forum.com/u/Ben_DJ)\
**Post date:** [April 3, 2010, 5:29am UTC](https://www.ruby-forum.com/t/building-nginx-with-non-system-openssl/186261/1 "2010-04-03T05:29:13Z")

</div>

Hi,

I’ve installed OpenSSL 1.0.0 in /usr/local/ssl; sources are in  
/usr/local/src/openssl.

Note,

pkg-config --libs “libcrypto” &&   
pkg-config --libs “libssl” &&   
pkg-config --libs “openssl”

```
-L/usr/local/ssl/lib -lcrypto -ldl -lz
-L/usr/local/ssl/lib -lssl -lcrypto -ldl -lz
-L/usr/local/ssl/lib -lssl -lcrypto -ldl -lz

```

I’m trying to build nginx so that it uses that openssl version’s  
libs/headers.

Noting configure’s options,

–with-openssl=DIR set path to OpenSSL library sources  
–with-openssl-opt=OPTIONS set additional options for OpenSSL  
building

(what, exactly, are the ‘additional options for OpenSSL building’  
supposed to be?)

If I,

./configure --with-http\_ssl\_module  
–with-openssl=/usr/local/src/openssl

I get,

Configuration summary  
+ using system PCRE library  
+ using OpenSSL library: /usr/local/src/openssl  
+ md5: using OpenSSL library  
+ sha1 library is not used  
+ using system zlib library

but,

make -j5

fails with,

make -f objs/Makefile  
make[1]: Entering directory `/data/src/nginx-0.8.35' cd /usr/local/src/openssl \ && make clean \ && ./config --prefix=/usr/local/src/openssl/.openssl no-shared no-threads \ && make \ && make install make[2]: Entering directory`/data/src/openssl’  
make[2]: \*\*\* No rule to make target `clean'. Stop. make[2]: Leaving directory`/data/src/openssl’  
make[1]: \*\*\* [/usr/local/src/openssl/.openssl/include/openssl/ssl.h]  
Error 2  
make[1]: Leaving directory `/data/src/nginx-0.8.35’  
make: \*\*\* [build] Error 2

I’d normally set ldflags, cppflags and cflags … but, afaict, they’re  
not referenced in nginx source,

egrep -i “ldflags|cflags|cppflags” .  
(empty)

How do I configure/build nging to use ‘my’ openssl?

Thanks,

BenDJ

---

<div class="post-metadata">

**Author:** ![Ben\_DJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/73ab20/32.png) [@Ben\_DJ](https://www.ruby-forum.com/u/Ben_DJ)\
**Post date:** [April 4, 2010, 12:05am UTC](https://www.ruby-forum.com/t/building-nginx-with-non-system-openssl/186261/2 "2010-04-04T00:05:51Z")

</div>

Hello!

On Fri, Apr 02, 2010 at 08:28:09PM -0700, Ben DJ wrote:

> I’ve installed OpenSSL 1.0.0 in /usr/local/ssl; sources are in  
> /usr/local/src/openssl.

[…]

> I’m trying to build nginx so that it uses that openssl version’s libs/headers.

If you want to use installed version, use:

./configure --with-cc-opt=“-I /path/to/include” --with-ld-opt=“-L  
/path/to/lib”

> Noting configure’s options,
> 
> –with-openssl=DIR set path to OpenSSL library sources  
> –with-openssl-opt=OPTIONS set additional options for OpenSSL building
> 
> (what, exactly, are the ‘additional options for OpenSSL building’  
> supposed to be?)

These options are used to build OpenSSL library from sources.  
Additional options are passed to OpenSSL’s ./config.

> If I,
> 
> ./configure --with-http\_ssl\_module --with-openssl=/usr/local/src/openssl

[…]

> make[1]: Leaving directory `/data/src/nginx-0.8.35’  
> make: \*\*\* [build] Error 2

Either you don’t have OpenSSL sources in /usr/local/src/openssl/  
or they are corrupted somehow. Vanilla OpenSSL 1.0.0 sources do  
have Makefile with target ‘clean’, try re-extracting them (if you  
really want nginx to build them instead of using already installed  
version).

> I’d normally set ldflags, cppflags and cflags … but, afaict, they’re  
> not referenced in nginx source,
> 
> egrep -i “ldflags|cflags|cppflags” .  
> (empty)

nginx do honor CFLAGS (use -r in grep, it helps), but not LDFLAGS.

> How do I configure/build nging to use ‘my’ openssl?

See above.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Ben\_DJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/73ab20/32.png) [@Ben\_DJ](https://www.ruby-forum.com/u/Ben_DJ)\
**Post date:** [April 4, 2010, 12:45am UTC](https://www.ruby-forum.com/t/building-nginx-with-non-system-openssl/186261/3 "2010-04-04T00:45:38Z")

</div>

Hi Maxim,

On Sat, Apr 3, 2010 at 3:05 PM, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If you want to use installed version, use:  
> ./configure --with-cc-opt=“-I /path/to/include” --with-ld-opt=“-L /path/to/lib”  
> …  
> These options are used to build OpenSSL library from sources.  
> Additional options are passed to OpenSSL’s ./config.

That clears it up, thanks. ‘cc-opt’ & ‘ld-opt’ were simply not clear to  
me.

I removed the --with-openssl= (though those _are_ vanilla sources  
…), and added,

ld-opt=“-L/usr/local/ssl/lib -Wl,-rpath,/usr/local/ssl/lib -lssl  
-lcrypto -ldl -lz”  
cc-opt=“-I/usr/local/include -I/usr/local/ssl/include -I/usr/include”

to ensure both that ‘my’ ssl libs are found before the system libs,  
and the rpath ensures the correct runtime dynamic lib links.

with those, it works,

ldd objs/nginx | egrep “ssl|crypto”  
libssl.so.1.0.0 =\> /usr/local/ssl/lib/libssl.so.1.0.0  
(0xb7849000)  
libcrypto.so.1.0.0 =\> /usr/local/ssl/lib/libcrypto.so.1.0.0  
(0xb76ca000)

which is exactly what i was looking to do.

> nginx do honor CFLAGS (use -r in grep, it helps), but not LDFLAGS.

actually, i _had_, just a typo in my post, but had failed to search  
from TOP\_DIR. :-/

in any case, nginx is up & running, and i’m working on configuring  
front-end proxy behavior 🙂

Thanks!

BenDJ
