部署nginx
下载新的模块解压
https://github.com/openresty/echo-nginx-module
[root@100 ~]# unzip echo-nginx-module-master.zip
重新编译nginx
[root@100 ~]# cd /usr/src
[root@100 src]# tar -zxf nginx-1.22.0.tar.gz
[root@100 src]# cd nginx-1.22.0/
[root@100 nginx-1.22.0]# ./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--add-module=/root/echo-nginx-module-master
查看objs目录下没有nginx程序
[root@100 nginx-1.22.0]# ls objs/
addon autoconf.err Makefile ngx_auto_config.h ngx_auto_headers.h ngx_modules.c src
进行编译后再查看
[root@100 nginx-1.22.0]# make
[root@100 nginx-1.22.0]# ls objs/
addon autoconf.err Makefile nginx nginx.8 ngx_auto_config.h ngx_auto_headers.h ngx_modules.c ngx_modules.o src
查看新编译的nginx参数
[root@100 nginx-1.22.0]# objs/nginx -V
nginx version: nginx/1.22.0
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-15) (GCC)
built with OpenSSL 1.1.1k FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --add-module=/root/echo-nginx-module-master
备份
[root@100 ~]# nginx -s stop
[root@100 ~]# cp /usr/local/nginx/sbin/nginx /opt/
覆盖
[root@100 ~]# cp /usr/src/nginx-1.22.0/objs/nginx /usr/local/nginx/sbin/
cp: overwrite '/usr/local/nginx/sbin/nginx'? y
启动服务
[root@100 ~]# /usr/local/nginx/sbin/nginx
[root@100 ~]# ss -antl
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
查看nginx参数
[root@100 ~]# nginx -V
nginx version: nginx/1.22.0
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-15) (GCC)
built with OpenSSL 1.1.1k FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --add-module=/root/echo-nginx-module-master
引用echo模块
[root@100 ~]# vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
echo "test";
}
检查配置文件内容
[root@100 ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
重载nginx
[root@100 ~]# nginx -s reload