游戏人生
首页
(current)
GameDevTools
登陆
|
注册
个人中心
注销
OpenResty 教程
OpenResty 简介
OpenResty Ubuntu安装
OpenResty 第一个例子
OpenResty 目录结构
OpenResty 启动和关闭
OpenResty 热重启
OpenResty 执行lua代码
OpenResty 执行lua文件
OpenResty 网站服务
OpenResty 访问指定网页
OpenResty 多网页网站
OpenResty 日志
OpenResty 流水线
OpenResty ip黑名单
OpenResty 反向代理
OpenResty 负载均衡
<< OpenResty Ubuntu安装
OpenResty 目录结构 >>
OpenResty 第一个例子 helloworld
第一个实例,输出 hello, world。 ------------ #### 1. 启动前的准备 ##### 1.创建工作目录 ```shell mkdir ~/work cd ~/work mkdir logs/ conf/ ``` ##### 2.创建 配置文件 ```shell nano conf/nginx.conf ``` 粘贴下面内容 ```shell worker_processes 1; error_log logs/error.log; events { worker_connections 1024; } http { server { listen 8080; location / { default_type text/html; content_by_lua_block { ngx.say("<p>hello, world</p>") } } } } ```  ctrl+o 保存 ctrl_x 退出 ##### 3.设置环境变量 为了能在任意文件夹使用OpenResty,需要添加环境变量。 执行下面命令 ```shell PATH=/usr/local/openresty/nginx/sbin:$PATH export PATH ``` ------------ #### 2. 启动OpenResty 执行下面命令启动 ```shell nginx -p `pwd`/ -c conf/nginx.conf ``` 没有报错,说明启动成功。  ------------ #### 3. 访问网站 打开浏览器,访问下面地址 ```shell http://localhost:8080/ ```  可以看到打开了网页,网页上显示了我们设置的内容。 或者使用 curl 命令来访问。 ```shell curl http://localhost:8080/ ``` 结果如下图 
<< OpenResty Ubuntu安装
OpenResty 目录结构 >>
提交
5ec8a6ecf9046103c7132d06