Search code examples
nginxgccamazon-amiamazon-linuxamazon-linux-2

How to install Nginx on Amazon linux 2 with the correct compiler options?


I'm trying to build a docker image with Amazon linux 2 as the base image, the build is failing during the installation of Nginx, the error is ./configure: error: the invalid value in --with-ld-opt="-Wl,-E"

What should be the value?

The installation script:

  #nginx source compile needs
  yum groupinstall -y "Development Tools" && \
  yum install -y zlib-devel pcre-devel openssl-devel gperftools-devel libxslt-devel perl-devel gd-devel GeoIP-devel wget java-11-openjdk && \
  #nginx runtime needs
  yum install -y openssl libxslt gd perl perl-ExtUtils-Embed GeoIP && \
  echo "Fetching nginx-1.22.0.tar.gz from nginx.org" && \
  wget -nv http://nginx.org/download/nginx-1.22.0.tar.gz -O /tmp/nginx-1.22.0.tar.gz && \
  echo "b33d569a6f11a01433a57ce17e83935e953ad4dc77cdd4d40f896c88ac26eb53 /tmp/nginx-1.22.0.tar.gz" | sha256sum -c - && \
  tar -zxf /tmp/nginx-1.22.0.tar.gz -C /opt/ && \
  rm -rf /tmp/nginx-1.22.0.tar.gz && \
  git clone https://github.com/AirisX/nginx_cookie_flag_module /opt/nginx_cookie_flag_module && \
  cd /opt/nginx-1.22.0 && \
  ./configure --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_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_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-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,-E' --add-dynamic-module=/opt/nginx_cookie_flag_module/ && \

The failure:

Fetching nginx-1.22.0.tar.gz from nginx.org
2022-11-24 18:15:27 URL:http://nginx.org/download/nginx-1.22.0.tar.gz [1073322/1073322] -> "/tmp/nginx-1.22.0.tar.gz" [1]
/tmp/nginx-1.22.0.tar.gz: OK
Cloning into '/opt/nginx_cookie_flag_module'...
checking for OS
 + Linux 5.10.124-linuxkit aarch64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 7.3.1 20180712 (Red Hat 7.3.1-15) (GCC)
checking for gcc -pipe switch ... found
checking for --with-ld-opt="-Wl,-E" ... not found
./configure: error: the invalid value in --with-ld-opt="-Wl,-E"

The command '/bin/bash -e -o pipefail -c yum groupinstall -y "Development Tools" &&   yum install -y zlib-devel pcre-devel openssl-devel gperftools-devel libxslt-devel perl-devel gd-devel GeoIP-devel wget java-11-openjdk &&   yum install -y openssl libxslt gd perl perl-ExtUtils-Embed GeoIP &&   echo "Fetching nginx-1.22.0.tar.gz from nginx.org" &&   wget -nv http://nginx.org/download/nginx-1.22.0.tar.gz -O /tmp/nginx-1.22.0.tar.gz &&   echo "b33d569a6f11a01433a57ce17e83935e953ad4dc77cdd4d40f896c88ac26eb53 /tmp/nginx-1.22.0.tar.gz" | sha256sum -c - &&   tar -zxf /tmp/nginx-1.22.0.tar.gz -C /opt/ &&   rm -rf /tmp/nginx-1.22.0.tar.gz &&   git clone https://github.com/AirisX/nginx_cookie_flag_module /opt/nginx_cookie_flag_module &&   cd /opt/nginx-1.22.0 &&   ./configure --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_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_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-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,-E' --add-dynamic-module=/opt/nginx_cookie_flag_module/ &&   make &&   make install &&   cd / &&   mkdir -p /var/lib/nginx/tmp &&   nginx -v &&   rm -rf /opt/nginx-1.22.0 &&   rm -rf /opt/nginx_cookie_flag_module &&   yum groupremove -y "Development Tools" &&   yum erase -y zlib-devel pcre-devel openssl-devel libxslt-devel perl-devel gd-devel GeoIP-devel wget &&   yum clean all &&   rm -rf /var/cache/yum &&   chown ctr-user:ctr-user /var/log/nginx &&   chown ctr-user:ctr-user /var/lib/nginx/tmp' returned a non-zero code: 1

Solution

  • It eventually worked once I removed the compilation options --with-cc-op and --with-ld-opt