Ngx_PageSpeed on my centOS 8 - nginx: [emerg] unknown directive "pagespeed"

134 views
Skip to first unread message

Paolo

unread,
May 8, 2020, 10:20:57 AM5/8/20
to ngx-pagespeed-discuss
I ran this code:
  1. bash <(curl -f -L -sS https://ngxpagespeed.com/install) \ --nginx-version latest
  2. ln -s /usr/local/nginx/conf/ /etc/nginx
  3. ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
  4. vi /etc/init.d/nginx and inserted this script:https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/
  5. systemctl start nginx +  systemctl enable nginx + # systemctl status nginx
  6. Added on my nginx.conf this script:
    # Pagespeed main settings
    
    pagespeed on;
    pagespeed FileCachePath /var/ngx_pagespeed_cache;
    
    
    # Ensure requests for pagespeed optimized resources go to the pagespeed
    # handler and no extraneous headers get set.
    
    location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
    location ~ "^/ngx_pagespeed_static/" { }
    location ~ "^/ngx_pagespeed_beacon" { }
and receive this messagge:
nginx: [emerg] unknown directive "pagespeed" in /etc/nginx/conf.d/examplepagespeed.com.conf:12

this is my output:
root@centOS8:/etc/nginx/conf.d# 2>&1 nginx -V | tr -- - '\n' | grep _module
http_ssl_module
http_v2_module
http_realip_module
http_addition_module
http_xslt_module=dynamic
http_image_filter_module=dynamic
http_sub_module
http_dav_module
http_flv_module
http_mp4_module
http_gunzip_module
http_gzip_static_module
http_random_index_module
http_secure_link_module
http_degradation_module
http_slice_module
http_stub_status_module
http_perl_module=dynamic
http_auth_request_module
mail_ssl_module
stream_ssl_module

Thank you for support

Paolo

unread,
May 8, 2020, 10:56:53 AM5/8/20
to ngx-pagespeed-discuss
I discovered this:

root@centOS8:/etc/nginx/conf.d# nginx -V
nginx version: nginx/1.14.1

built by gcc 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC)
built with OpenSSL 1.1.1 FIPS  11 Sep 2018 (running with OpenSSL 1.1.1c FIPS  28 May 2019)
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-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-debug --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

root@centOS8:/etc/nginx/conf.d# /usr/local/nginx/sbin/nginx -V | tr -- - '\n' | grep _module
nginx version: nginx/1.18.0

built by gcc 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)
configure arguments: --add-module=/root/incubator-pagespeed-ngx-latest-stable
root@centOS8:/etc/nginx/conf.d#

Longinos

unread,
May 8, 2020, 1:16:58 PM5/8/20
to ngx-pagespeed-discuss
Hi
You have 2 nginx installations, 1 version 1.14.1 and other version 1.18.0. Your system is starting the cersion 1.14.1 that don´t have the pagespeed module, so this throw the error that th directive pagespeed in your nginx.confile is unkow.
The step 4 is unneeded, nginx is started/stoped with systemd not by init ( you started nginx and make it enabled in step 5)
The systemd service files for nginx are pointing to the nginx version 1.14.1

Paolo

unread,
May 10, 2020, 4:47:18 AM5/10/20
to ngx-pagespeed-discuss
oook. thank you for support
Reply all
Reply to author
Forward
0 new messages