Skip to content

实战-OpenResty安装实践-20250118(测试成功)

实战:OpenResty安装实践-2025.1.18(测试成功)

image-20250114064951324

版权

本内容来自:《极客时间:Nginx 核心知识 150 讲》,版权归原作者所有,这里仅记录自己的学习笔记。

环境

bash
openresty-1.13.6.2nginx1.13.6centos7

源码

官网下载源码包:

https:yuminstall-ygcc-c++opensslopenssl-develpcrepcre-develzlibzlib-devel-y#如果你用的是CentOS,那么搭环境非常简单,安装这些包后,make就能准备好nginx编译的基本环境

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)

image-20250118075449061

  • 配置:(添加如下代码)
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"])';}……

image-20250118081523427

  • 启动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上做下域名解析:

image-20250118081607821

192.168.1.102 test.one.cn

  • 验证

浏览器输入域名:(可以看到OpenResty界面了,另外通过f12检查可以看到响应头里Server是openresty/1.13.6.2了。)

image-20250118081650538

  • 输入\lua再次验证

正常就可以看到OpenResty返回给我们的数据了。

image-20250118081822719

结束。

FAQ

源码包结构

image-20250118074645837

bundle目录:

nginx的第三方模块(c语言写的);

lua模块(lua语言写的);

查看帮助

[root@localhost openresty-1.13.6.2]# ./configure --help|more查看帮助

image-20250114071553362

关于我

我的博客主旨:

  • 排版美观,语言精炼;
  • 文档即手册,步骤明细,拒绝埋坑,提供源码;
  • 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!

🍀 个人网站

image-20250109220325748

🍀 微信二维码

x2675263825 (舍得), qq:2675263825。

image-20230107215114763

🍀 微信公众号

《云原生架构师实战》

image-20230107215126971

🍀 csdn

https:

版权:此文章版权归 One 所有,如有转载,请注明出处!

链接:可点击右上角分享此页面复制文章链接

上次更新时间:

最近更新