incubator-pagespeed-ngx icon indicating copy to clipboard operation
incubator-pagespeed-ngx copied to clipboard

Build error for nginx 1.15.8 (invalid option "-DNGX_HTTP_HEADERS'")

Open yucolabjames opened this issue 6 years ago • 3 comments
trafficstars

This is a manual build with NGINX installed via the official pre-built repo on Ubuntu 18.04

deb https://nginx.org/packages/mainline/ubuntu/ bionic nginx
deb-src https://nginx.org/packages/mainline/ubuntu/ bionic nginx

Commands that am using to build page speed:

Downloading page speed

NPS_VERSION=1.13.35.2-stable
wget https://github.com/apache/incubator-pagespeed-ngx/archive/v${NPS_VERSION}.zip
unzip v${NPS_VERSION}.zip
nps_dir=$(find . -name "*pagespeed-ngx-${NPS_VERSION}" -type d)
cd "$nps_dir"
NPS_RELEASE_NUMBER=${NPS_VERSION/beta/}
NPS_RELEASE_NUMBER=${NPS_VERSION/stable/}
psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_RELEASE_NUMBER}.tar.gz
[ -e scripts/format_binary_url.sh ] && psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL)
wget ${psol_url}
tar -xzvf $(basename ${psol_url})  # extracts to psol/

Setting build flags

PS_NGX_EXTRA_FLAGS="--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules 
--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log 
--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid 
--lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp 
--http-proxy-temp-path=/var/cache/nginx/proxy_temp 
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp 
--http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio 
--with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module 
--with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module 
--with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module 
--with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module 
--with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module 
--with-stream_ssl_module --with-stream_ssl_preread_module 
--with-cc-opt='-g -DNGX_HTTP_HEADERS' --with-ld-opt='-Wl,-Bsymbolic-functions'"

Getting NGINX

NGINX_VERSION=1.15.8
cd
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/
./configure --add-dynamic-module=$HOME/$nps_dir ${PS_NGX_EXTRA_FLAGS}
make
sudo make install

Error encountered: ./configure: error: invalid option "-DNGX_HTTP_HEADERS'"

Building with the flag would result in module "/usr/local/nginx/modules/ngx_pagespeed.so" is not binary compatible in /etc/nginx/nginx.conf:4

Been looking at issues #1440 and #1612 but no go... Any help would be greatly appreciated. Thanks guys!

yucolabjames avatar Jan 11 '19 03:01 yucolabjames

The error is emitted by ‘configure’, which probably is a hint: perhaps you need to quote ‘${PS_NGX_EXTRA_FLAGS}’ when passing it?

oschaaf avatar Jan 13 '19 15:01 oschaaf

Thanks for pointing me into the right direction, adding a single quote didn't work and double quote broke it even more with an error: Makefile:18: *** missing separator. Stop.

What I resorted doing is pasting the variable in a single line which worked but the binary obtained is still invalid

./configure --add-dynamic-module=$HOME/$nps_dir  --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -DNGX_HTTP_HEADERS' --with-ld-opt='-Wl,-Bsymbolic-functions'

Error on restarting nginx:

Jan 14 09:54:46 www-dev systemd[1]: Starting nginx - high performance web server...
Jan 14 09:54:46 www-dev nginx[21741]: nginx: [emerg] module "/usr/local/nginx/modules/ngx_pagespeed.so" is not binary compatible in /etc/nginx/nginx.conf:4
Jan 14 09:54:46 www-dev systemd[1]: nginx.service: Control process exited, code=exited status=1
Jan 14 09:54:46 www-dev systemd[1]: nginx.service: Failed with result 'exit-code'.

yucolabjames avatar Jan 14 '19 01:01 yucolabjames

That is unfortunate. Figuring out what the module signature looks like for the distro-provided nginx in ubuntu 18.04 and how it diverges from the one in your ngx_pagespeed.so is possible but annoying. You can see how the signature gets composed here: https://github.com/nginx/nginx/blob/4bf4650f2f10f7bbacfe7a33da744f18951d416d/src/core/ngx_module.h#L21

oschaaf avatar Jan 14 '19 15:01 oschaaf