通常而言,我们需要nginx某些特定的功能,可以通过源码方式,在预编译时添加第三方模块来实现。
但是有的朋友可能为了省事,直接通过yum安装了nginx,那yum方式管理的nginx可以直接加载模块来实现某些特定功能么?
答案是可以的,这里我们以echo模块来说,echo模块在为我们做location匹配以及调试方面很有帮助。
yum install epel* -y
yum install https://extras.getpagespeed.com/release-el7-latest.rpm -yecho模块版本需要与nginx的版本一致,如果当前nginx版本与echo版本不一致,会自动升级:
yum install nginx-module-echo -y要使用该模块功能,需要在配置文件中的main指令块(也就是最上面的全局配置)下添加模块引用:
load_module modules/ngx_http_echo_module.so;location / {
echo yes;
}
[root@localhost ~]# curl 192.168.0.108
yes本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。