apache / incubator-pagespeed-ngx

Automatic PageSpeed optimization module for Nginx
http://ngxpagespeed.com/
Apache License 2.0
4.37k stars 363 forks source link

How to configure additional modules to nginx after installation? #1716

Open zamanuhina opened 3 years ago

zamanuhina commented 3 years ago

Hello.

# nginx -V
nginx version: nginx/1.15.4
built by gcc 6.4.0 (Alpine 6.4.0)
built with LibreSSL 2.7.4
TLS SNI support enabled
configure arguments: --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-http_ssl_module --with-http_realip_module --with-http_addition_module --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_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-http_slice_module --with-mail --with-mail_ssl_module --with-compat --with-file-aio --with-http_v2_module --add-module=/usr/src/ngxpagespeed --with-ld-opt='-Wl,-z,relro,--start-group -lapr-1 -laprutil-1 -licudata -licuuc -lpng -lturbojpeg -ljpeg'

I need to add a module.

--add-module=/usr/src/my-custom-module

But if I take all the previous configuration, then PageSpeed probably won't install, since the folder is empty.

# ls /usr/src/ngxpagespeed
ls: /usr/src/ngxpagespeed: No such file or directory

How can you add a module without breaking PageSpeed?

Lofesa commented 3 years ago

configure arguments: --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-http_ssl_module --with-http_realip_module --with-http_addition_module --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_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-http_slice_module --with-mail --with-mail_ssl_module --with-compat --with-file-aio --with-http_v2_module --add-module=/usr/src/ngxpagespeed --with-ld-opt='-Wl,-z,relro,--start-group -lapr-1 -laprutil-1 -licudata -licuuc -lpng -lturbojpeg -ljpeg'

That´s the output of the compile options. Have you compile the module w/o errors? From this output I see --add-module=/usr/src/ngxpagespeed, in this directory is where the source code of pagespeed come at the compilation time, If you install nginx+pagespeed from a package maybe empty. But the modules must reside at --modules-path=/usr/lib/nginx/modules , so in this directory must be the .so files. In the nginx.conf ( must be here. --conf-path=/etc/nginx/nginx.conf ) you need to include: load_module /usr/lib/nginx/modules/ngx_pagespeed.so; before the http block, at the same level you have user or worker_processes

ghost commented 3 years ago

You will most likely need to compile pagespeed into that folder before compiling nginx:

There are a few ways you can do that as either a static or dynamic module, instructions are at the link below

https://www.modpagespeed.com/doc/build_ngx_pagespeed_from_source

zamanuhina commented 3 years ago

I forgot to mention that this is Nginx in Docker.

https://github.com/apache/incubator-pagespeed-ngx/tree/master/docker