nginx安装http_image_filter_module模块(系统模块)

配置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`

nginx: [emerg] unknown directive "image_filter" in /usr/local/nginx/conf/vhost/wounion.conf

提示指令不存在。

因为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。就不会报模块错误了。
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值