1.下载stream-lua-nginx-module模块:

(https://github.com/openresty/stream-lua-nginx-module#installation)github地址

cd /usr/local/openresty

命令:git clone https://github.com/openresty/stream-lua-nginx-module.git

2.添加环境变量:

 export LUAJIT_LIB=/usr/local/openresty/luajit/lib
 export LUAJIT_INC=/usr/local/openresty/luajit/include/luajit-2.1

3.编译stream-lua-nginx-module

wget  http://openresty.org/download/ngx_openresty-1.9.7.4.tar.gz

tar -zxvf  ngx_openresty-1.9.7.4.tar.gz

cd ngx_openresty-1.9.7.4

输入nginx -V命令,将参数添加上来即可

./configure --prefix=/usr/local/openresty --with-cc-opt='-O2 -I/usr/local/Cellar/openssl/1.0.2h_1/include/ -I/usr/local/Cellar/pcre/8.39/include/'  --with-stream --with-stream_ssl_module --add-module=/usr/local/openresty/stream-lua-nginx-module --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/Cellar/openssl/1.0.2h_1/lib/ -L/usr/local/Cellar/pcre/8.39/lib/' --with-http_ssl_module

make

make install

编译安装完后查看nginx参数:

请看图片最后!!!,此时表明已经安装成功

4.学习stream模块:

在nginx.conf文件中加上红色框框内代码,即可构建一个tcp server,端口号为1234

5.连接socket tcp服务端:

法一:通过telnet方法验证

法二:通过socket 连接来验证:

此时表明stream的tcp server已经创建成功啦!

 

 

 

转载于:https://my.oschina.net/u/2263272/blog/808368

Logo

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。

更多推荐