OpenResty®-英文官网地址:http://openresty.org/en/

OpenResty®-中文官网地址: http://openresty.org/cn/

OpenResty®> https://openresty.org/en/linux-packages.html
centos yun-command
sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
sudo yum install openresty-resty //安装resty命令行实用程序
下载> https://openresty.org/en/download.html
源代码> https://openresty.org/download/openresty-1.15.8.2.tar.gz
# [root@localhost openresty-1.15.8.2]# yum install -y gcc gcc-c++ iptables-services perl pcre-devel openssl-devel zlib wget lrzsz ntpdate
# [root@localhost src]# wget https://openresty.org/download/openresty-1.15.8.2.tar.gz -P /usr/local/src
# [root@localhost src]# tar -zxvf openresty-1.15.8.2.tar.gz
# [root@localhost src]# cd openresty-1.15.8.2
# [root@localhost openresty-1.15.8.2]# ls
# bundle configure COPYRIGHT patches README.markdown README-windows.txt util
# [root@localhost openresty-1.15.8.2]# ./configure
# Configuration summary
# + using system PCRE library
# + using system OpenSSL library
# + using system zlib library
#
# nginx path prefix: "/usr/local/openresty/nginx"
# nginx binary file: "/usr/local/openresty/nginx/sbin/nginx"
# nginx modules path: "/usr/local/openresty/nginx/modules"
# nginx configuration prefix: "/usr/local/openresty/nginx/conf"
# nginx configuration file: "/usr/local/openresty/nginx/conf/nginx.conf"
# nginx pid file: "/usr/local/openresty/nginx/logs/nginx.pid"
# nginx error log file: "/usr/local/openresty/nginx/logs/error.log"
# nginx http access log file: "/usr/local/openresty/nginx/logs/access.log"
# nginx http client request body temporary files: "client_body_temp"
# nginx http proxy temporary files: "proxy_temp"
# nginx http fastcgi temporary files: "fastcgi_temp"
# nginx http uwsgi temporary files: "uwsgi_temp"
# nginx http scgi temporary files: "scgi_temp"
#
# cd ../..
# Type the following commands to build and install:
# gmake
# gmake install
# [root@localhost openresty-1.15.8.2]# gmake && gmake install
# make[]: Leaving directory `/usr/local/src/openresty-1.15.8.2/build/nginx-1.15.'
# make[]: Leaving directory `/usr/local/src/openresty-1.15.8.2/build/nginx-1.15.'
# mkdir -p /usr/local/openresty/site/lualib /usr/local/openresty/site/pod /usr/local/openresty/site/manifest
# ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/local/openresty/bin/openresty
# [root@localhost openresty-1.15.8.2]# cd /usr/local/openresty/
# [root@localhost openresty]# ls
# bin COPYRIGHT luajit lualib nginx pod resty.index site
# [root@localhost openresty]# ll bin |grep openresty
# lrwxrwxrwx root root Oct : openresty -> /usr/local/openresty/nginx/sbin/nginx
[root@localhost sbin]# ln -sf `pwd`/nginx /usr/local/sbin/nginx
# !bin/bash
# echo '#!/bin/bash
# chkconfig:
# nginx=/usr/local/openresty/nginx/sbin/nginx
# case "$1" in
# start)
# echo "Starting nginx daemon..."
# $nginx && echo "Success"
# ;;
# stop)
# echo "Stopping nginx daemon..."
# $nginx -s stop && echo "Success"
# ;;
# reload)
# echo "Reloading nginx daemon..."
# $nginx -s reload && echo "Success"
# ;;
# restart)
# echo "Restarting nginx daemon..."
# $nginx -s quit
# $nginx && echo "Success"
# ;;
# reopen)
# echo "Reopening nginx daemon..."
# $nginx -s reopen && echo "Success"
# ;;
# *)
# echo "Please useing nginx {start|stop|retart|reload|reopen}"
# exit2
# ;;
# esac' > /etc/init.d/nginx
# chmod /etc/init.d/nginx
# chkconfig --add nginx
# chkconfig --level nginx on //0-6运行级别可用
# [root@localhost sbin]# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT
# [root@localhost sbin]# service iptables save
# iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
# [root@localhost sbin]# systemctl restart iptables
# [root@localhost sbin]# iptables -L -n
# Chain INPUT (policy ACCEPT)
# target prot opt source destination
# ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
#
# Chain FORWARD (policy ACCEPT)
# target prot opt source destination
#
# Chain OUTPUT (policy ACCEPT)
# target prot opt source destination
# [root@localhost sbin]# nginx
# [root@localhost sbin]# nginx -s reload # 关于OpenResty目录结构的具体说明如下
# ●bin:存放二进制可执行文件.
# ●luajit:存放LuaJIT(Lua代码解释器)相关的文件.
# ●lualib:存放Lua库文件.
# ●nginx:OpenResty整合的Nginx存放在这个目录.
# ●pod:存放用于bin/restydoc程序读取的pod文档.
# ●resty.in ndex:存放pod文档的索引.
# ●site:OPM(OpenResty Package Manager)包的存放目录. # OpenResty主要应用在一些对性能要求非常高的场合,例如WAF(Web Application Firewall,Web应用防火墙)、
# CDN(Content Delivery Network,内容分发网络)调度、广告系统、消息推送系统、RESTful API(一种服务器接口技术)等.
# 一些知名的互联网公司如 CloudFlare 、奇虎360、新浪、京东等都在使用OpenResty相关的技术.
# OpenResty平台离不开 Nginx 和 Lua 语言,读者可通过GitHub开源平台中的openresty-best practices. # [root@localhost bin]# ./resty -e 'print("hello,my name is kings-dev.")'
# hello,my name is kings-dev.
# [root@localhost bin]# ./restydoc -s proxy_pass
# ngx_http_proxy_module() nginx ngx_http_proxy_module()
#
#
#
# proxy_pass
# syntax: proxy_pass "URL"
#
# context: location
#
# context: if in location
#
# context: limit_except
#
# Sets the protocol and address of a proxied server and an optional URI
# to which a location should be mapped. As a protocol, “"http"” or
# “"https"” can be specified. The address can be specified as a domain
# name or IP address, and an optional port:
#
# proxy_pass http://localhost:8000/uri/;
#
# or as a UNIX-domain socket path specified after the word “"unix"” and
# enclosed in colons:
#
# proxy_pass http://unix:/tmp/backend.socket:/uri/;
#
# If a domain name resolves to several addresses, all of them will be
# used in a round-robin fashion. In addition, an address can be
# specified as a server group.
#
# Parameter value can contain variables. In this case, if an address is
# specified as a domain name, the name is searched among the described
# server groups, and, if not found, is determined using a
# ngx_http_core_module.
#
# A request URI is passed to the server as follows:
#
# · If the "proxy_pass" directive is specified with a URI, then when a
# request is passed to the server, the part of a normalized request
# URI matching the location is replaced by a URI specified in the
# directive:
#
# location /name/ {
# proxy_pass http://127.0.0.1/remote/;
# }
#
# · If "proxy_pass" is specified without a URI, the request URI is
# passed to the server in the same form as sent by a client when the
# original request is processed, or the full normalized request URI
# is passed when processing the changed URI:
#
# location /some/path/ {
# proxy_pass http://127.0.0.1;
# }
#
# NOTE
# ngx_http_proxy_module() nginx ngx_http_proxy_module()
#
#
#
# proxy_pass
# syntax: proxy_pass "URL"
#
# context: location
#
# context: if in location
#
# context: limit_except
#
# Sets the protocol and address of a proxied server and an optional URI
# to which a location should be mapped. As a protocol, “"http"” or
# “"https"” can be specified. The address can be specified as a domain
# name or IP address, and an optional port:
#
# proxy_pass http://localhost:8000/uri/;
#
# or as a UNIX-domain socket path specified after the word “"unix"” and
# enclosed in colons:
#
# proxy_pass http://unix:/tmp/backend.socket:/uri/;
#
# If a domain name resolves to several addresses, all of them will be
# used in a round-robin fashion. In addition, an address can be
# specified as a server group.
#
# Parameter value can contain variables. In this case, if an address is
# specified as a domain name, the name is searched among the described
# server groups, and, if not found, is determined using a
# ngx_http_core_module.
#
# A request URI is passed to the server as follows:
#
# · If the "proxy_pass" directive is specified with a URI, then when a
# request is passed to the server, the part of a normalized request
# URI matching the location is replaced by a URI specified in the
# directive:
#
# location /name/ {
# proxy_pass http://127.0.0.1/remote/;
# }
#
# · If "proxy_pass" is specified without a URI, the request URI is
# passed to the server in the same form as sent by a client when the
# original request is processed, or the full normalized request URI
# is passed when processing the changed URI:
#
# location /some/path/ {
# proxy_pass http://127.0.0.1;
# }
#
# NOTE
#
# Before version 1.1., if "proxy_pass" is specified without a URI,
# the original request URI might be passed instead of the changed URI
# in some cases.
#
# In some cases, the part of a request URI to be replaced cannot be
# determined:
#
# · When location is specified using a regular expression, and also
# inside named locations.
#
# In these cases, "proxy_pass" should be specified without a URI.
#
# · When the URI is changed inside a proxied location using the
# ngx_http_rewrite_module directive, and this same configuration will
# be used to process a request ("break"):
#
# location /name/ {
# rewrite /name/([^/]+) /users?name=$ break;
# proxy_pass http://127.0.0.1;
# }
#
# In this case, the URI specified in the directive is ignored and the
# full changed request URI is passed to the server.
#
# · When variables are used in "proxy_pass":
#
# location /name/ {
# proxy_pass http://127.0.0.1$request_uri;
# }
#
# In this case, if URI is specified in the directive, it is passed to
# the server as is, replacing the original request URI.
#
# WebSocket proxying requires special configuration and is supported
# since version 1.3..
#
#
#
# OpenResty -- ngx_http_proxy_module() # [root@localhost bin]# cd
# [root@localhost ~]# mkdir openresty_work
# [root@localhost ~]# cd openresty_work/
# [root@localhost openresty_work]# mkdir logs conf
# [root@localhost openresty_work]# ls -lF
# total
# drwxr-xr-x root root Oct : conf/
# drwxr-xr-x root root Oct : logs/ # [root@localhost openresty_work]# vi openresty_nginx_conf.sh #!/bin/bash
echo "worker_processes 1;
error_log logs/error.log;
events {
worker_connections ;
}
http {
server {
listen ;
location /{
default_type text/html;
content_by_lua_block {
ngx.say('<p>Hello World</p>')
}
}
}
}" > /root/openresty_work/conf/nginx.conf # [root@localhost openresty_work]# sh openresty_nginx_conf.sh
# [root@localhost openresty_work]# ls -lF conf/nginx.conf
# -rw-r--r-- root root Oct : conf/nginx.conf
# [root@localhost openresty_work]# nginx -s stop
# [root@localhost openresty_work]# nginx -p
# [root@localhost openresty_work]# nginx -p .
# [root@localhost openresty_work]# curl localhost:
# <p>Hello World</p>
# 在上述配置中, content_by_lua_file 指令用于引入外部文件, lua_code_cache 用于开启或关闭 lua 文件缓存.
# 在默认情况下会对lua文件进行缓存以提高效率,而在开发环境可以临时关闭缓存以方便测试.
# [root@localhost openresty_work]# vi test_lua_nginx.sh
# [root@localhost openresty_work]# sh test_lua_nginx.sh #!/bin/bash
echo 'worker_processes 1;
error_log logs/error.log;
events {
worker_connections ;
}
http {
server {
listen ;
location /test.lua{
lua_code_cache off;
content_by_lua_file test.lua;
}
}
}' > /root/openresty_work/conf/nginx.conf # [root@localhost openresty_work]# echo "ngx.say('<h1>hi,my name is kings-dev.</h1>')" > test.lua
# [root@localhost openresty_work]# cat test.lua
# ngx.say('<h1>hi,my name is kings-dev.</h1>')
# [root@localhost openresty_work]# nginx -p . -s reload
# nginx: [alert] lua_code_cache is off; this will hurt performance in ./conf/nginx.conf:
# [root@localhost openresty_work]# curl localhost:/test.lua
# <h1>hi,my name is kings-dev.</h1>

centos 7 OpenResty®(lua-nginx-module)搭建可扩展的Web平台的更多相关文章

  1. 用lua nginx module搭建一个二维码

    用lua nginx module搭建一个二维码(qr code)生成器 作者 vinoca 發布於 2014年10月31日 如果有VPS,或者开源的路由器,安装一个nginx,添加lua-nginx ...

  2. CentOS 环境下基于 Nginx uwsgi 搭建 Django 站点

    因为我的个人网站 restran.net 已经启用,博客园的内容已经不再更新.请访问我的个人网站获取这篇文章的最新内容,CentOS 环境下基于 Nginx uwsgi 搭建 Django 站点 以下 ...

  3. Centos 7 Docker、docker-compose、Registrator、Consul、Consul Template和Nginx实现高可扩展的Web框架

    安装所需软件 Docker Docker-compose 配置docker-compose.yml文件内容如下: #load balancer will automatically update th ...

  4. CentOS安装OpenResty(Nginx+Lua)开发环境

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

  5. nginx 与 lua 开发环境搭建

    首先下载最新版的 相关软件 的安装文件. nginx: http://nginx.org/en/download.html LuaJIT: http://luajit.org/download.htm ...

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

    关于 http://openresty.org/cn/about.html 这个开源 Web 平台主要由章亦春(agentzh)维护.在 2011 年之前曾由淘宝网赞助,在后来的 2012 ~ 201 ...

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

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

  8. nginx整合php+lua+oracle环境搭建

    nginx整合php+lua+oracle环境搭建 标签: nginxluaoraclephplinux -- : 1473人阅读 评论() 收藏 举报 分类: 技术() 版权声明:本文为博主原创文章 ...

  9. 在阿里云 CentOS 服务器(ECS)上搭建 nginx + mysql + php-fpm 环境

    阿里云的云服务器(ECS)可以选择多种操作系统,打算用它运行 Drupal或者 WordPress ,你最好选择 Linux 系统,这篇文章的演示是基于阿里云的 CentOS 操作系统的服务器.我们在 ...

随机推荐

  1. powershell自动添加静态IP

    声明:其中脚本有参考其他作者,由于当时参考仓促,未能把作者一一列出,有机会会再找出原作者文件链接并附上,请见谅 参考: https://ss64.com/nt/netsh.html https://w ...

  2. 质量保障&&质量体系建设

    一.质量保障 先引用一段 百度百科 上对软件质量保障的解释:软件质量保障是建立一套有计划,系统的方法,来向管理层保证拟定出的标准.步骤.实践和方法能够正确地被项目所采用.软件质量保证的目的是使软件过程 ...

  3. CPU-内存-IO-网络调优

    一.关于CPU 中央处理器调优 1. CPU处理方式: 批处理,顺序处理请求.(切换次数少,吞吐量大) 分时处理.(如同"独占",吞吐量小)(时间片,把请求分为一个一个的时间片,一 ...

  4. ssm整合的spring.xml文件配置(applicationContext.xml)

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

  5. redis单机版无法启动java程序解决

    1.注释掉 bind 127.0.0.1 2.kill-9 杀死进行 3.redis-server + 配置文件进行重启,

  6. day32 网络编程之粘包问题

    1.最大半连接数 什么是最大半连接数 半连接:在进行TCP协议通信时,客户端与服务器端进行三次握手建立连接,但是有时客户端与服务器端进行了连接申请,服务器端也同意了申请(既已经完成三次握手的两次),此 ...

  7. ssm框架的小总结

    一.mybatis框架 mybatis框架主要就是完成持久层的实现,简化了持久层的开发, 1.首先是配置文件的编写,我们这里就命名为mybatis-config.xml,先配置文件头,然后加载连接数据 ...

  8. # codeblocks 使用技巧+伪单文件编译

    codeblocks 使用技巧+伪单文件编译 shift+F2打开和隐藏左侧工作空间 F2 打开和隐藏下面控制台 CTRL+Shift+c 注释,CTRL+Shift+x取消注释 view->p ...

  9. tp5项目报错no input file specified解决

    关于这个问题众多解决方案 1.php版本问题>5.6,把php版本改成5.5版本 2.入口文件同级目录下的.htaccess文件 RewriteRule ^(.*)$ index.php/$1 ...

  10. Java中的自动拆装箱(转)

    出处: 一文读懂什么是Java中的自动拆装箱 本文主要介绍Java中的自动拆箱与自动装箱的有关知识.  基本数据类型 基本类型,或者叫做内置类型,是Java中不同于类(Class)的特殊类型.它们是我 ...