---
title: "openrest 操作 redis 相关"
author: "yjph83"
date: "2021-11-02T13:13:57Z"
tags: []
categories: ["互联网"]
slug: "openrest-redis"
draft: false
lastmod: "2021-11-02T13:43:28Z"
id: 2521353
url: "https://yjph83.iteye.com/blog/2521353"
---

OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台，其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。本质上就是一个Nginx+Lua的集成软件。

 

1、可以采用官网 [http://openresty.org/en/download.html](http://openresty.org/en/download.html) 下载安装新版本；

2、也可以命令工具安装

    

```bash
[root@docker ~]# yum install yum-utils
[root@docker ~]# yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
[root@docker ~]# yum install openresty
[root@docker ~]# yum install openresty-resty
```

系统默认安装在`/usr/local/openresty/`目录下,版本如下

 

```bash
[root@docker openresty]# cd /usr/local/openresty/bin/
[root@docker bin]# ./openresty -v
nginx version: openresty/1.19.9.1
```

 

wget https://raw.githubusercontent.com/pintsized/lua-resty-http/master/lib/resty/http\_headers.lua

wget https://raw.githubusercontent.com/pintsized/lua-resty-http/master/lib/resty/http.lua

放在/usr/local/openresty/lualib/resty目录下，对应用来http相关的组件；

下边就可以用lua来操作redis组件了，因为openresty已经包含了lua-resty-redis组件了；  可以参考文档：[https://github.com/openresty/lua-resty-redis](https://github.com/openresty/lua-resty-redis)

 

3、脚本编写的时候

A、直接在nginx.conf  location 下添加：

 

https://www.cnblogs.com/xiao-xue-di/p/12972674.html

openresty 系列教程基本就是这个

 [https://www.cnblogs.com/xiao-xue-di/category/1289827.html](https://www.cnblogs.com/xiao-xue-di/category/1289827.html)

[https://www.it610.com/article/1298515155335847936.htm](https://www.it610.com/article/1298515155335847936.htm)