yum install nginx new module http_image_filter_module notes

Probably the idea of ​​nginx yum install new modules

  1. Official nginx.org download the same version of nginx source package

  2. Compiled and installed and specify the needed modules (corresponding to third party modules with a separate download package)

  3. Note compile only make, do not install make install. Will generate an executable file compiled in objs directory nginx

  4. Nginx executable file to copy cp objs / nginx / usr / sbin /


First, download the source package

Yum install the current version of nginx: nginx -v 1.16.0

Current nginx executable file: which nginx / usr / sbin / nginx, a good idea to back up this file

nginx.org not found 1.16.0, 1.16.1 here to download the source package instead

Download and extract to: /usr/local/nginx-1.16.1 directory

Start by compiling a backup before:

Backup Source nginx cp / usr / sbin / nginx /usr/sbin/nginx.bak

Backup configuration files nginx cp -r / etc / nginx /etc/nginx.bak

Second, the compiler configuration parameters

View nginx already installed modules nginx -V

./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 --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='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

In the above command inside with --with-http_image_filter_module = started when the dynamic compilation, the compiler-dependent module is not installed causes an error corresponding to the module can be installed simply.

I have a compile time dependency is not installed two modules:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

安装pcre-devel: yum install pcre-devel

./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.

Installation gd-devel: yum install gd-devel

In short what is missing on what is installed, many online articles have introduced all dependent modules.

Third, compile the source package

Execute make, remember not need to do make install, just need to get here nginx recompiled executable file does not need to reinstall replace the original nginx

Execution is completed will generate a corresponding executable file in the directory nginx objs

Copy image filtering module: cp objs / ngx_http_image_filter_module.so / usr / lib64 / nginx / modules /

Covering nginx executable file: cp -rfp objs / nginx / usr / sbin /

Four, nginx configuration files

/etc/nginx/nginx.conf dynamically loaded modules: load_module "modules / ngx_http_image_filter_module.so";

/etc/nginx/conf.d/test.conf configuration picture processing

location ~* /(.+)\.(jpg|jpeg|gif|png)!(\d+)x(\d+)$ {
              set $w $3;
              set $h $4;
              image_filter resize  $w $h;
              image_filter_buffer  10M;
              image_filter_jpeg_quality 75;
              try_files /$1.$2  /notfound.jpg;
             #  expires 30d;
          }

nginx -t check nginx configuration syntax is OK, you can restart nginx

Fifth, the test image zoom

Artwork visit:

Thumbnail go to:

Refer to the following two is enough ah

https://blog.csdn.net/zzy5066/article/details/81136273

https://www.cnblogs.com/lixigang/articles/5130052.html

https://www.cnblogs.com/tinywan/p/6965467.html Nginx dynamic loading module

Guess you like

Origin www.cnblogs.com/zqsb/p/11388889.html