配置image_filter
1. 配置
location ~* /images/.*\.(jpg|gif|png)$ {
# root /home/wwwroot/default/wounion/dragonfly/public/;
image_filter resize 100 100;
image_filter_buffer 100M;
}
2. 重启nginx
`sudo nginx -s reload`
提示指令不存在。
因为http_image_filter_module 模块并没有安装。
如何安装呢?
安装image_filter模块依赖的库。
sudo apt-get install libgd2-xpm-dev
查看之前的配置
nginx -V
--prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-pcre=../pcre-8.37 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.1.0e --add-module=/opt/othersoft/nginx1.18/nginx-1.18.0/third_module/echo-nginx-module-0.61
添加上图片模块【由于它是系统模块,不需要额外下载,直接添加就可以了】
sudo ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-pcre=../pcre-8.37 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.1.0e --add-module=/opt/othersoft/nginx1.18/nginx-1.18.0/third_module/echo-nginx-module-0.61 --with-http_image_filter_module
进入安装nginx的文件夹中,保证版本一致
pwd
/usr/local/lnmp1.4-full/src/nginx-1.12.2
sudo ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-pcre=../pcre-8.37 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.1.0e --add-module=/opt/othersoft/nginx1.18/nginx-1.18.0/third_module/echo-nginx-module-0.61 --with-http_image_filter_module
sudo make
提示
安装系统库
yum -y install gd-devel
再执行编译命令
替换二进制文件,最好做一个备份
sudo cp -f objs/nginx /usr/local/nginx/sbin/nginx
重新查看nginx -V
# nginx -V
我们发现成功的安装了图片处理模块。
这个时候,重新启动nginx。就不会报模块错误了。