#查看编译配置 ./configure --help | cat --helpprint this message
--prefix=PATH set installation prefix --sbin-path=PATH set nginx binary pathname --modules-path=PATH set modules path --conf-path=PATH set nginx.conf pathname --error-log-path=PATH set error log pathname --pid-path=PATH set nginx.pid pathname --lock-path=PATH set nginx.lock pathname
--user=USER set non-privileged user for worker processes --group=GROUP set non-privileged group for worker processes
--build=NAME set build name --builddir=DIR set build directory
--with-http_perl_module enable ngx_http_perl_module --with-http_perl_module=dynamic enable dynamic ngx_http_perl_module --with-perl_modules_path=PATH set Perl modules path --with-perl=PATH set perl binary pathname
--http-log-path=PATH set http access log pathname --http-client-body-temp-path=PATH set path to store http client request body temporary files --http-proxy-temp-path=PATH set path to store http proxy temporary files --http-fastcgi-temp-path=PATH set path to store http fastcgi temporary files --http-uwsgi-temp-path=PATH set path to store http uwsgi temporary files --http-scgi-temp-path=PATH set path to store http scgi temporary files
--without-http disable HTTP server --without-http-cache disable HTTP cache
--with-cc=PATH set C compiler pathname --with-cpp=PATH set C preprocessor pathname --with-cc-opt=OPTIONS set additional C compiler options --with-ld-opt=OPTIONS set additional linker options --with-cpu-opt=CPU build for the specified CPU, valid values: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, sparc32, sparc64, ppc64
--without-pcre disable PCRE library usage --with-pcre force PCRE library usage --with-pcre=DIR set path to PCRE library sources --with-pcre-opt=OPTIONS set additional build options for PCRE --with-pcre-jit build PCRE with JIT compilation support
--with-zlib=DIR set path to zlib library sources --with-zlib-opt=OPTIONS set additional build options for zlib --with-zlib-asm=CPU use zlib assembler sources optimized for the specified CPU, valid values: pentium, pentiumpro
--with-libatomic force libatomic_ops library usage --with-libatomic=DIR set path to libatomic_ops library sources
--with-openssl=DIR set path to OpenSSL library sources --with-openssl-opt=OPTIONS set additional build options for OpenSSL
--with-debug enable debug logging
从上面的帮助可以看到,主要的编译配置分为3类
配置文件位置指定
指定使用和不使用的模块with(增加编译)、without(移除编译)
优化参数、第三方模块,日志位置等
1 2
#编译,指定位置 ./configure --prefix=/home/nginx
可能会出现报错
1 2 3 4
./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.
根据提示,可以安装对应的库,或者在编译的时候选择移除对应的模块,或者选择从源码编译
1 2
#安装 pcre library yum -y install pcre-devel
再次编译提示缺少 zlib
1 2 3 4
./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option.
1 2
# 安装zlib library yum -y install zlib-devel
再次编译以后,提示编译成功,以及nginx 相关的路径、模块等目录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Configuration summary + using system PCRE library + OpenSSL library is not used + using system zlib library