OpenResty 基础知识 和 Linux部署 详解

4 篇文章 0 订阅
OpenResty (又称 : ngx_openresty) 是一个基于 NGINX 的可伸缩的 Web 平台,可以使用 Lua脚本语言 调动 Nginx 支持的各种 C 以及 Lua 模块,OpenResty 性能优异。OpenResty 可以快速构造出 1W+ 并发连接响应的超高性能 Web 应用系统

OpenResty 可以将 Nginx+Lua 打包在一起,而且提供包括 Redis客户端,MySQL 客户端,http客户端等在内的大量的组件

中文官方网站 :  http://openresty.org/cn/


Linux 部署 OpenResty
安装 OpenResty 依赖库
# yum install readline-devel pcre-devel openssl-devel gcc

下载并解压最新稳定版 openresty  http://openresty.org/cn/download.html
# cd /opt/softwares/
# wget https://openresty.org/download/openresty-1.13.6.1.tar.gz
# tar -zxvf openresty-1.13.6.1.tar.gz -C /opt/modules/

编译并安装 OpenResty 相关软件
# cd /opt/modules/openresty-1.13.6.1

# cd bundle/LuaJIT-2.1-20171103
# make clean && make && make install
...
==== Successfully installed LuaJIT 2.1.0-beta3 to /usr/local ====    # 安装成功,且在 创建 /usr/local/bin/luajit 软连接

# cd /opt/modules/openresty-1.13.6.1/bundle
# wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz    # 在 https://github.com/FRiCKLE/ngx_cache_purge/releases 下载最新稳定版
# tar -xvf 2.3.tar.gz

# cd /opt/modules/openresty-1.13.6.1/bundle
# wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz    # 在 https://github.com/yaoweibin/nginx_upstream_check_module/releases 下载最新稳定版
# tar -xvf v0.3.0.tar.gz

# 将 ngx_cache_purge nginx_upstream_check_module 进行打包编译在一起
# cd /opt/modules
# mkdir openresty
# cd /opt/modules/openresty-1.13.6.1
# ./configure --prefix=/opt/modules/openresty --with-http_realip_module  --with-pcre  --with-luajit --add-module=./bundle/ngx_cache_purge-2.3/ --add-module=./bundle/nginx_upstream_check_module-0.3.0/ -j2
# make && make install

# cd /opt/modules/openresty
# ll
总用量 244
drwxr-xr-x  2 root root    123 5月  10 20:02 bin
-rw-r--r--  1 root root  22924 5月  10 20:02 COPYRIGHT
drwxr-xr-x  6 root root     56 5月  10 20:02 luajit
drwxr-xr-x  6 root root     70 5月  10 20:02 lualib
drwxr-xr-x  6 root root     54 5月  10 20:02 nginx
drwxr-xr-x 44 root root   4096 5月  10 20:02 pod
-rw-r--r--  1 root root 218352 5月  10 20:02 resty.index
drwxr-xr-x  5 root root     47 5月  10 20:02 site

如果出现
错误: 无法验证 github.com 的由 “/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended Validation Server CA” 颁发的证书: 颁发的证书还未生效。
可以再 wget 中增加 --no-check-certificate 参数,进行下载
# wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz --no-check-certificate

启动编译好的 nginx
# cd /opt/modules/openresty
# ./nginx/sbin/nginx

# ps -ef|grep nginx    # 检查 nginx,发现 nginx 可以正常运行,说明 nginx 运行成功
root      23767      1  0 20:08 ?        00:00:00 nginx: master process ./sbin/nginx
nobody    23768  23767  0 20:08 ?        00:00:00 nginx: worker process
root      23771   6506  0 20:08 pts/5    00:00:00 grep --color=auto nginx


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值