一,简介
nginx 的 echo 模块,可以使你的nginx能输出自定义的信息.
二,安装
下载安装包
点击进入GITHUB安装地址
注意自己的版本,选择与自己nginx兼容的版本下载哦
解压
下载后 上传到任意文件夹 解压
tar -zxvf echo-nginx-module-0.62.tar.gz
编译
如果已安装过nginx 输入获取./configure参数
nginx -V
没有安装过 可以自行搜索一下nginx安装的相关文章
./configure --user=www --group=www --prefix=/www/server/nginx --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --with-openssl=/www/server/nginx/src/openssl --with-pcre=pcre-8.43 --with-http_v2_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_stub_status_module --with-http_ssl_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-ld-opt=-Wl,-E --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc --with-http_dav_module --add-module=/www/server/nginx/src/nginx-dav-ext-module
静态加载模块
上面是我获取到我已安装的 编辑参数 把echo模块加入到上面即可
--add-module=/www/server/nginx/src/echo-nginx-module
而后
make
make install
动态加载模块
动态加载 与静态加载不同之处在于添加到./configure的内容不同
--add-dynamic-module=/www/server/nginx/src/echo-nginx-module
拼接起来就是
./configure --user=www --group=www --prefix=/www/server/nginx…–add-dynamic-module=/www/server/nginx/src/echo-nginx-module
而后
make
make install
操作完成后 在 /nginx/modules/
目录下 会生成一个 ngx_http_echo_module.so
文件
我们只需在nginx.conf 的 全局块中动态引入模块即可
load_module /www/server/nginx/modules/ngx_http_echo_module.so;