本文共 1414 字,大约阅读时间需要 4 分钟。
[root@localhost ~]# yum install git -y
[root@localhost ~]# git clone https://github.com/openresty/echo-nginx-module.git
查看服务器上现有的nginx所带有的相关模块
[root@localhost ~]# nginx -Vnginx version: nginx/1.14.2built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)built with OpenSSL 1.0.2k-fips 26 Jan 2017TLS SNI support enabledconfigure arguments: --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
重新编译nginx带上以上模块,再追加一个echo-nginx-module
[root@localhost nginx-1.14.2]# ./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --add-module=/root/echo-nginx-module
[root@localhost nginx-1.14.2]# make && make install
[root@localhost ~]# systemctl restart nginx
修改配置文件
server { server_name www.mylinuxops.com; location /echo { echo "hello world"; # 测试echo模块 }}
访问echo页面
[root@localhost ~]# curl http://www.mylinuxops.com/echohello world
转载于:https://blog.51cto.com/11886307/2403948