关于

http://openresty.org/cn/about.html

这个开源 Web 平台主要由章亦春(agentzh)维护。在 2011 年之前曾由淘宝网赞助,在后来的 2012 ~ 2016 年间主要由美国的 CloudFlare 公司 提供支持。目前,OpenResty® 主要由 OpenResty 软件基金会和 OpenResty Inc. 公司提供支持。

因为大部分 Nginx 模块都是由本软件包的维护者开发,所以可以确保所有这些模块及其他组件可以很好地一起工作。

打包的各个软件组件版权属于各自的版权持有者。

本网站是一个全动态的 Web 应用,完全基于 OpenResty® 平台和 PostgreSQL 数据库构建。其实现开源在 下面这个 GitHub 仓库中:

https://github.com/openresty/openresty.org

如果你希望编辑和改进这个网站的话,请随意建立这个仓库的分支,或者直接联系我们索取 git 提交权限。

OpenResty®

 

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

OpenResty® 通过汇聚各种设计精良的 Nginx 模块(主要由 OpenResty 团队自主开发),从而将 Nginx 有效地变成一个强大的通用 Web 应用平台。这样,Web 开发人员和系统工程师可以使用 Lua 脚本语言调动 Nginx 支持的各种 C 以及 Lua 模块,快速构造出足以胜任 10K 乃至 1000K 以上单机并发连接的高性能 Web 应用系统。

OpenResty® 的目标是让你的Web服务直接跑在 Nginx 服务内部,充分利用 Nginx 的非阻塞 I/O 模型,不仅仅对 HTTP 客户端请求,甚至于对远程后端诸如 MySQL、PostgreSQL、Memcached 以及 Redis 等都进行一致的高性能响应。

参考 组件 可以知道 OpenResty® 中包含了多少软件。

参考 上路 学习如何从最简单的 hello world 开始使用 OpenResty® 开发 HTTP 业务,或前往 下载 直接获取 OpenResty® 的源代码包开始体验。

构建 OpenResty

http://openresty.org/cn/installation.html

下载

从下载页 Download下载最新的 OpenResty® 源码包,并且像下面的示例一样将其解压:

tar -xzvf openresty-VERSION.tar.gz

VERSION 的地方替换成您下载的源码包的版本号,比如说 0.8.54.6

./configure

然后在进入 openresty-VERSION/ 目录, 然后输入以下命令配置:

./configure

默认, --prefix=/usr/local/openresty 程序会被安装到/usr/local/openresty目录。

您可以指定各种选项,比如

./configure --prefix=/opt/openresty \
--with-luajit \
--without-http_redis2_module \
--with-http_iconv_module \
--with-http_postgres_module

试着使用 ./configure --help 查看更多的选项。

配置文件(./configure script)运行出错可以到 build/nginx-VERSION/objs/autoconf.err 找到。 VERSION 的地方必须与OpenResty版本号相对应, 比如 0.8.54.6

Solaris的用户请注意:

对于 Solaris,安装开发库一般通过 OpenSSL 的形式插入 /lib, 因此当编译时出现 missing OpenSSL 说明您已经安装过了t, 特别是一些选项的时候 --with-ld-opt='-L/lib' 。

make

您可以使用下面的命令来编译:

make

如果您的电脑支持多核 make 工作的特性, 您可以这样编译:

make -j2

假设您是的机器是双核。

make install

如果前面的步骤都没有问题的话,您可以使用下面的命令安装l OpenResty到您的系统之中:

make install

在 Linux,通常包括 sudo来执行root权限做的事情。

 

Getting Started

Yichun Zhang, 03 Nov 2011 (created 20 Jun 2011)

 

First of all, please go to the Download page to get the source code tarball of OpenResty, and see the Installation page for how to build and install it into your system.

HelloWorld

Prepare directory layout

We first create a separate directory for our experiments. You can use an arbitrary directory. Here for simplicity, we just use ~/work:

mkdir ~/work
cd ~/work
mkdir logs/ conf/

Note that we've also created the logs/ directory for logging files and conf/ for our config files.

Prepare the nginx.conf config file

Create a simple plain text file named conf/nginx.conf with the following contents in it:

worker_processes  1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}

If you're familiar with Nginx configuration, it should look very familiar to you. OpenResty is just an enhanced version of Nginx by means of addon modules anyway. You can take advantage of all the exisitng goodies in the Nginx world.

Start the Nginx server

Assuming you have installed OpenResty into /usr/local/openresty (this is the default), we make our nginx executable of our OpenResty installation available in our PATH environment:

PATH=/usr/local/openresty/nginx/sbin:$PATH
export PATH

Then we start the nginx server with our config file this way:

nginx -p `pwd`/ -c conf/nginx.conf

Error messages will go to the stderr device or the default error log files logs/error.log in the current working directory.

Access our HelloWorld web service

We can use curl to access our new web service that says HelloWorld:

curl http://localhost:8080/

If everything is okay, we should get the output

<p>hello, world</p>

You can surely point your favorite web browser to the location http://localhost:8080/.

Test performance

See Benchmark for details.

Where to go from here

View the documentation of each component at the Components page and find Nginx related stuff on the Nginx Wiki site.

OpenResty:通过 Lua 扩展 NGINX 实现的可伸缩的 Web 平台的更多相关文章

  1. 通过 Lua 扩展 NGINX 实现的可伸缩的 Web 平台OpenResty®

    OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库.第三方模块以及大多数的依赖项.用于方便地搭建能够处理超高并发.扩展性极高的动态 W ...

  2. 给lnmp一键包中的nginx安装openresty的lua扩展

    lnmp一键包(https://lnmp.org)本人在使用之后发现确实好用,能帮助我们快速搭建起lnmp.lamp和lnmpa的web生产环境,因此推荐大家可以多试试.但有的朋友可能需要使用open ...

  3. OpenResty入门之使用Lua扩展Nginx

    记住一点:nginx配置文件很多坑来源自你的空格少了或多了. 1.Centos下载安装 如果你的系统是 Centos 或 RedHat 可以使用以下命令: yum install readline-d ...

  4. openresty安装lua和nginx相关

    server{ listen ; server_name a.com; index index.php; root /usr/share/nginx/html; location / { if (!- ...

  5. 通过lua扩展nginx

    1. 安装 准备主要的三个安装包,分别是 nginx-1.15.9.tar.gz LuaJIT-2.0.5.tar.gz lua-nginx-module-0.10.14.tar.gz 相关版本可以去 ...

  6. 通过lua进行nginx的权限控制

    nginx_lua的安装 nginx使用luajit进行编译安装 使用openresty进行yum安装 openresty中将lua和nginx进行封装,详情可查看openresty官网 openre ...

  7. 用lua扩展你的Nginx(整理)-----openresty

    用lua扩展你的Nginx(整理) 首先得声明.这不是我的原创,是在网上搜索到的一篇文章,原著是谁也搞不清楚了.按风格应该是属于章亦春的文章. 整理花了不少时间,所以就暂写成原创吧. 一. 概述 Ng ...

  8. 用lua扩展你的Nginx(整理)

    首先得声明.这不是我的原创,是在网上搜索到的一篇文章,原著是谁也搞不清楚了.按风格应该是属于章亦春的文章. 整理花了不少时间,所以就暂写成原创吧. 一. 概述 Nginx是一个高性能.支持高并发的,轻 ...

  9. OpenResty 最佳实践 lua与nginx的结合 --引用自https://moonbingbing.gitbooks.io/openresty-best-practices/content/

    系统的说明了lua在nginx上的开发 请大家到源址查看 OpenResty最佳实践

随机推荐

  1. 【漫画】以后在有面试官问你平衡(AVL)树,你就把这篇文章扔给他。

    西天取经的路上,一样上演着编程的乐趣..... 1.若它的左子树不为空,则左子树上所有的节点值都小于它的根节点值. 2.若它的右子树不为空,则右子树上所有的节点值均大于它的根节点值. 3.它的左右子树 ...

  2. 【C#加深理解系列】(一)反射

    什么是反射 反射是.NET中的重要机制,通过反射,可以在运行时获得程序或程序集中每一个类型(包括类.结构.委托.接口和枚举等)的成员和成员的信息.有了反射,即可对每一个类型了如指掌.另外我还可以直接创 ...

  3. 【API知识】一种你可能没见过的Controller形式

    前言 这里分享一下我遇到的一个挺有意思的Controller形式,内容涉及@RequestMapping注解的原理. 实际案例 一.基本描述 项目甲中有多个模块,其中就有模块A和B.(这里的模块指的是 ...

  4. -1-2 java 面向对象基本概念 封装继承多态 变量 this super static 静态变量 匿名对象 值传递 初始化过程 代码块 final关键字 抽象类 接口 区别 多态 包 访问权限 内部类 匿名内部类 == 与 equal

    java是纯粹的面向对象的语言 也就是万事万物皆是对象 程序是对象的集合,他们通过发送消息来相互通信 每个对象都有自己的由其他的对象所构建的存储,也就是对象可以包含对象 每个对象都有它的类型  也就是 ...

  5. Python四步实现决策树ID3算法,参考机器学习实战

    一.编写计算历史数据的经验熵函数 from math import log def calcShannonEnt(dataSet): numEntries = len(dataSet) labelCo ...

  6. Ubuntu中安装 mercurial – TortoiseHG

    sudo add-apt-repository ppa:tortoisehg-ppa/releases sudo add-apt-repository ppa:mercurial-ppa/releas ...

  7. 一键解决 go get golang.org/x 包失败

    问题描述 当我们使用 go get.go install.go mod 等命令时,会自动下载相应的包或依赖包.但由于众所周知的原因,类似于 golang.org/x/... 的包会出现下载失败的情况. ...

  8. App阅读pdf和扫描二维码功能

    在之前开发的Android手机App中,需要实现阅读pdf和扫描二维码的功能,在github 上找到大牛封装好包,亲测可用. 阅读pdf: https://github.com/barteksc/An ...

  9. sql 参数化查询问题

    一.正确案例 string name=“梅”; string sql="select * from test where  Name  like @Name"; //包含 梅Sql ...

  10. 20190321-HTML基本结构

    目录 1.HTML概念 超文本标记语言 2.HTML版本 HTML HTML5 3.HTML基本结构 基本结构 元素.标签.属性 4.HTML常用标签 内容 1.HTML概念 HTML(HyperTe ...