Unable to build Nginx (unrecognized option) - nginx

I am having some issues when configuring nginx, I have the following:
./configure \
--user=www-data \
--group=www-data \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-debug \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-file-aio \
--with-http_realip_module \
--with-http_v2_module \
--with-pcre-jit \
--with-ipv6 \
--add-module=/root/modsecurity \
--add-module=/root/ngx_pagespeed-1.12.34.2-beta ${PS_NGX_EXTRA_FLAGS} \
--add-module=/root/headers-more-nginx
But I am getting the following error:
configure: error: unrecognized option: `--user=www-data'
If I try removing that option then the next option will give the exact same.
Does anyone know what I am doing wrong here?
Thanks!

Strangely I managed to fix it by removing the following:
--add-module=/root/modsecurity \

Related

Fail compile nginx from source

dockerfile
FROM ubuntu:20.04
WORKDIR /tmp
COPY build.sh /tmp
RUN ./build.sh
build script
#!/bin/bash
set -xe
NGINX_DIR="/etc/nginx"
mkdir -p ${NGINX_DIR}
mkdir -p ${NGINX_DIR}/temp
mkdir -p /tmp/nginx_bin
apt update -y && apt install wget gcc make libpcre3 libpcre3-dev zlib1g-dev libssl-dev libgeoip-dev automake -y
wget https://nginx.org/download/nginx-1.22.1.tar.gz -P /tmp && tar zxvf /tmp/nginx-1.22.1.tar.gz -C /tmp
cd /tmp/nginx-1.22.1 && ./configure \
--with-debug \
--prefix=${NGINX_DIR} \
--sbin-path=${NGINX_DIR}/sbin/nginx \
--conf-path=${NGINX_DIR}/nginx.conf \
--pid-path=${NGINX_DIR}/logs/nginx.pid \
--lock-path=${NGINX_DIR}/logs/nginx.lock \
--error-log-path=${NGINX_DIR}/logs/error.log \
--http-log-path=${NGINX_DIR}/logs/access.log \
--with-cc-opt="-O2 -g -Wno-error" \
--with-ld-opt="-static" \
--with-pcre-jit \
--http-client-body-temp-path=${NGINX_DIR}/temp/client_body_temp \
--http-proxy-temp-path=${NGINX_DIR}/temp/proxy_temp \
--with-stream \
--with-stream_ssl_module \
--with-file-aio \
--with-threads \
--with-http_geoip_module \
--with-http_auth_request_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_v2_module \
--with-http_slice_module \
--with-http_gunzip_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_dav_module \
--with-http_sub_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--with-openssl-opt="-g" && make -j4 && make -j4 install && cp objs/nginx /tmp/nginx_bin
I use the above dockerfile and shell script to compile nginx from source, if remove --with-ld-opt="-static" parameter, it will compile success, but after I add --with-ld-opt="-static" parameter, the complie will fail with the below error
checking for GeoIP library ... not found
checking for GeoIP library in /usr/local/ ... not found
checking for GeoIP library in /usr/pkg/ ... not found
checking for GeoIP library in /opt/local/ ... not found
but I already install the libgeoip-dev when running shell script
Could any one help take a look, how to fix it, thanks.
I use the above dockerfile and shell script to compile nginx from source, if remove --with-ld-opt="-static" parameter, it will compile success, but after I add --with-ld-opt="-static" parameter, the complie will fail with the below error
checking for GeoIP library ... not found
checking for GeoIP library in /usr/local/ ... not found
checking for GeoIP library in /usr/pkg/ ... not found
checking for GeoIP library in /opt/local/ ... not found

How to install nginx without the modules in RedHat

I install nginx using Yum following these steps:
yum install epel-release
yum install nginx
The following is the output of nginx -V:
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.1.1c FIPS 28 May 2019 (running with OpenSSL 1.1.1g FIPS 21 Apr 2020)
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
How can I install nginx without the --with*
In order to do that you must install nginx from source.
First download the tar.gz file from http://nginx.org/en/download.html then run the following command for compiling and installing:
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --user=nginx --group=nginx --build=CentOS --builddir=nginx-1.18.0 --with-http_gunzip_module --with-http_gzip_static_module
make sure to edit the version in builddir as your current version
run for compiling: make
for installing run make install
nginx is part of RHEL 8. Suggest installing that one: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/deploying_different_types_of_servers/setting-up-and-configuring-nginx_deploying-different-types-of-servers

geoip2 for nginx not wirking

i have Problem with compile "geoip2" for nginx. my ".so" is not working.
my install way:
cd /opt/
sudo add-apt-repository ppa:maxmind/ppa && apt update & sudo apt install libmaxminddb0 libmaxminddb-dev mmdb-bin
git clone https://github.com/leev/ngx_http_geoip2_module.git
wget http://nginx.org/download/nginx-1.15.8.tar.gz && tar xzfv nginx-1.15.8.tar.gz && cd nginx-1.15.8/
./configure --with-compat --add-dynamic-module=/opt/ngx_http_geoip2_module && make && make install
... test ! -f '/usr/local/nginx/modules/ngx_http_geoip2_module.so' \
|| mv '/usr/local/nginx/modules/ngx_http_geoip2_module.so' \
'/usr/local/nginx/modules/ngx_http_geoip2_module.so.old' cp
objs/ngx_http_geoip2_module.so
'/usr/local/nginx/modules/ngx_http_geoip2_module.so' make[1]: Leaving
directory '/opt/nginx-1.15.8 ...
cp /usr/local/nginx/modules/ngx_http_geoip2_module.so /usr/share/nginx/modules/ngx_http_geoip2_module.so
adding the line load_module "modules/ngx_http_geoip2_module.so"; in my nginx.conf an restart nginx.
and after restart is geoip2 not loaded in my nginx install
nginx version: nginx/1.15.8 built with OpenSSL 1.1.1 11 Sep 2018
(running with OpenSSL 1.1.1a 20 Nov 2018) TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2
-fdebug-prefix-map=/build/nginx-2CZdMa/nginx-1.15.8=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-compat --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-mail=dynamic --with-mail_ssl_module --add-dynamic-module=/build/nginx-2CZdMa/nginx-1.15.8/debian/modules/http-auth-pam
--add-dynamic-module=/build/nginx-2CZdMa/nginx-1.15.8/debian/modules/http-dav-ext
--add-dynamic-module=/build/nginx-2CZdMa/nginx-1.15.8/debian/modules/http-echo
--add-dynamic-module=/build/nginx-2CZdMa/nginx-1.15.8/debian/modules/http-upstream-fair
--add-dynamic-module=/build/nginx-2CZdMa/nginx-1.15.8/debian/modules/http-subs-filter
who is my fail or problem?
There is no problem. You seem to be copying the dynamic module to existing nginx installation.
The nginx -V will show the configure command that was used while compiling nginx. So it won't show configure options for the dynamic module that you compiled in a separate step, and it won't show loaded modules.
Just use the module's directives. It should work.

Compile Nginx with module from source in Centos error

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx.conf--error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_image_filter_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-debug
objs/ngx_modules.o \
-lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lz -lGeoIP
make[1]: Leaving directory `/tmp/nginx-1.8.0'
make -f objs/Makefile manpage
make[1]: Entering directory `/tmp/nginx-1.8.0'
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
-e "s|%%PID_PATH%%|/var/run/nginx.pid|" \
-e "s|%%CONF_PATH%%|/etc/nginx/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/var/log/nginx/error.log|" \
< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/tmp/nginx-1.8.0'
Why show error compiled? How fixed? Thank you. OS: Centos 6.5. ; Source Nginx compile 1.8
Here Is full log
http://pastebin.com/zVgurAig

Nginx unable to find libpcre.so.0 after install from source

I am building nginx from source on ubuntu 14.04 but after building, when I run nginx I get the following error:
/etc/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.0:
cannot open shared object file: No such file or directory
The reason is probably because it is called libpcre.so.3. Is there a package I can install for libpcre0?
Can I configure nginx to use libpcre.so.3 somehow?
Here is the how to compile Nginx with OpenSSL and Pcre-8.36, with custom Username and Group for additional privileges:
./configure --with-cc-opt="-I $STATICLIBSSL/include -I/usr/include" \
--with-ld-opt="-L $STATICLIBSSL/lib -Wl,-rpath -lssl -lcrypto -ldl -lz" \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-pcre=/lib/libpcre.so.1
--with-http_ssl_module \
--with-http_spdy_module \
--with-file-aio \
--with-ipv6 \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--without-mail_pop3_module \
--without-mail_smtp_module \
--without-mail_imap_module \
--user=nginx \
--group=nginx \
--with-http_spdy_module \
--with-http_auth_request_module \
--with-openssl=/root/openssl/openssl-1.0.2a/libssl.a
--with-zlib=/usr/lib/x86_64-linux-gnu/libz.a

Resources