实战-OpenResty安装实践-20250118(测试成功)
实战:OpenResty安装实践-2025.1.18(测试成功)
版权
本内容来自:《极客时间:Nginx 核心知识 150 讲》,版权归原作者所有,这里仅记录自己的学习笔记。
环境
bash
openresty-1.13.6.2nginx1.13.6centos7
源码
官网下载源码包:
1、下载
下载源码包:
bash
cd/root/wgethttps:tarxfopenresty-1.13.6.2.tar.gzcdopenresty-1.13.6.2
2、编译
bash
#在openresty-1.13.6.2目录下执行./configuremakemakeinstall
3、配置
查看下默认openresty的配置文件在哪里?
bash
[root@localhost openresty-1.13.6.2]# ./configure --help|more--prefix=PATHsettheinstallationprefix(default to/usr/local/openresty)
- 配置:(添加如下代码)
bash
[root@localhost ~]# vim /usr/local/openresty/nginx/conf/nginx.conf……server_nametest.one.cn;location/lua{default_typetext/html;content_by_lua'ngx.say("User-Agent:",ngx.req.get_headers()["User-Agent"])';}……
- 启动nginx:
bash
[root@localhost openresty]# /usr/local/openresty/nginx/sbin/nginx [root@localhost openresty]# ps -ef|grepnginxroot182581007:56?00:00:00nginx:masterprocess/usr/local/openresty/nginx/sbin/nginxnobody1825918258007:56?00:00:00nginx:workerprocessroot182619690007:57pts/000:00:00grep--color=autonginx[root@localhost openresty]# #重载nginx:/usr/local/openresty/nginx/sbin/nginx-sreload
4、验证
- 验证前,先在自己pc上做下域名解析:
192.168.1.102 test.one.cn
- 验证
浏览器输入域名:(可以看到OpenResty界面了,另外通过f12检查可以看到响应头里Server是openresty/1.13.6.2
了。)
- 输入
\lua
再次验证
正常就可以看到OpenResty返回给我们的数据了。
结束。
FAQ
源码包结构
bundle目录:
nginx的第三方模块(c语言写的);
lua模块(lua语言写的);
查看帮助
[root@localhost openresty-1.13.6.2]# ./configure --help|more
查看帮助
关于我
我的博客主旨:
- 排版美观,语言精炼;
- 文档即手册,步骤明细,拒绝埋坑,提供源码;
- 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!
🍀 个人网站
🍀 微信二维码
x2675263825 (舍得), qq:2675263825。
🍀 微信公众号
《云原生架构师实战》
🍀 csdn