When I run nginx -V
I get something like this in the output.
--with-ld-opt='-lrt -ljemalloc -Wl,-z,relro' --with-cc-opt='-m64 -mtune=native -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wno-sign-compare -Wno-string-plus-int -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-const-variable -Wno-conditional-uninitialized -Wno-mismatched-tags -Wno-c++11-extensions -Wno-sometimes-uninitialized -Wno-parentheses-equality -Wno-tautological-compare -Wno-self-assign -Wno-deprecated-register -Wno-deprecated -Wno-invalid-source-encoding -Wno-pointer-sign -Wno-parentheses -Wno-enum-conversion'
What is this and how to know which values need to go here when compiling nginx from source code ?
Out of the box you probably do not need to provide any flags yourself, the configure script should detect automatically some reasonable defaults.
However, in order to optimize for speed and/or security, you should probably provide a few compiler flags. Red Hat published an article about the flag collections they consider good. The flags starting with
-Wl
are used by the linker, so you should provide them using--with-ld-opt
. E.g.-Wl,-pie
would become--with-ld-opt="-pie"
.Another reasonable way to do it would be to copy the options used by your distribution provided packages. The maintainer probably knows what he was doing, and you at least know it works for your use case.
This Nginx option shows configuration options (needed to set-up your compilator and linker):
As this documentation page says -> http://nginx.org/en/docs/configure.html:
So first ones are what you want to add to a linker (ld), second is intended for a compiler (cc, gcc, etc.). For more information about these options refer gcc man page: https://linux.die.net/man/1/gcc
When you enter the following command:
nginx -V -h
where:
-V: : show version and configure options then exit
So you can configure your build accordingly using various parameters. The build can be configured using the configure command.
Configure according to your need and wherever you are stuck just add
-h
for getting the information about a particular argument in your configuration.