游戏人生
首页
(current)
GameDevTools
登陆
|
注册
个人中心
注销
OpenResty 教程
OpenResty 简介
OpenResty Ubuntu安装
OpenResty 第一个例子
OpenResty 目录结构
OpenResty 启动和关闭
OpenResty 热重启
OpenResty 执行lua代码
OpenResty 执行lua文件
OpenResty 网站服务
OpenResty 访问指定网页
OpenResty 多网页网站
OpenResty 日志
OpenResty 流水线
OpenResty ip黑名单
OpenResty 反向代理
OpenResty 负载均衡
<< OpenResty 执行lua文件
OpenResty 访问指定网页 >>
OpenResty 网站服务
在第一个例子中,使用浏览器访问 访问下面地址 ```shell http://localhost:8080/ ``` 就可以查看OpenResty 返回的内容。 那么实际上,OpenResty返回的内容就是网页内容。 下面通过一个简单的例子,使用OpenResty 返回简单的网页。 -------------------------------------------------------------------------------- #### 1. 修改lua脚本 修改 `service/http/test.lua` 为以下内容。 ```shell local sHtmlCode=[[<html> <head> <title>ThisisGame powerd by OpenResty</title> </head> <body> <img src="https://www.thisisgame.com.cn/static/img/1590140364061190311.jpg"/> </body> </html>]] ngx.say(sHtmlCode) ``` ------------ #### 2.重启/启动 OpenResty 服务 重启 OpenResty: ```shell nginx -p `pwd`/ -s reload ``` ------------ #### 3. 访问网站 打开浏览器,访问下面地址 ```shell http://localhost:8080/ ```  可以看到,正常显示了网页内容。 再稍稍扩展一下,就可以写出一个新浪微博了。 加油少年。
<< OpenResty 执行lua文件
OpenResty 访问指定网页 >>
提交
5ec8e7f4f9046103c7132d0c