强大的 Web 应⽤服务器OpenResty安装(Nginx仓库)

2023-12-07 0 130

OpenResty(⼜称:ngx_openresty) 是一个基于 NGINX 的可伸缩的 Web 平台,OpenResty 是⼀个强大的 Web 应⽤服务器,Web 开发⼈员可以使用 Lua 脚本语⾔调动 Nginx ⽀持的各种 C 以及 Lua 模块,更主要的是在性能方面,OpenResty可以快速构造出足以胜任 10K 以上并发连接响应的超高性能 Web 应用系统

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中⽂官网: http://openresty.org/cn/

windows版安装

1.运⾏⼀个Hello World

在任意⼀个地⽅新建⼀个⽂件夹(注意最好不要有中⽂路径)。例如:在桌面新建⼀个 example 文件夹, ⽬录结构如下 (⽬录树生成网站 http://dir.yardtea.cc/)

强大的 Web 应⽤服务器OpenResty安装(Nginx仓库)

2.其中logs和conf是必要的,⾥面的⽂件可以新建空文件。

3.打开nginx.conf如⼀配置:

worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 9000;
default_type text/html;
location / {
root /data/html;
index kbn.html;
}
} }

4.启动nginx

nginx -p /bin -c conf/nginx.conf或 cd /var/nginx/bin目录使用 nginx -c conf/nginx.conf如果启动报错 resty.core 找不到, 就把nginx安装目录中的lua,luaLib 两个⽂件夹复制到project ⾥面去

5.修改配置之后使⽤ ./nginx -s reload 重启

停⽌./nginx -s stop

ConterOS 安装 OpenResty

下载地址:OpenResty官⽹: http://openresty.org/OpenResty下载地址:http://openresty.org/cn/download.html

  • 安装依赖库:

$ yum install -y pcre-devel openssl-devel gcc curl

2.下载OpenResty版本:

$ wget https://openresty.org/download/openresty-1.15.8.1.tar.gz
wget https://openresty.org/download/openresty-1.21.4.1.tar.gz

  • 解压:

$ tar -xzvf openresty-1.15.8.1.tar.gz

  • 进⼊解压⽬目录:

$ cd openresty-1.15.8.1/

  • 检查配置环境, ⽣成 Makefile,默认安装到/usr/local/openresty:

$ ./configure

  • 编译安装:

$ gmake && gmake install

安装结果:

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

可以看到openresty 实际上是nginx的软连接。7.常用命令:

查看版本号:
$ /usr/local/openresty/bin/openresty -v
nginx version: openresty/1.15.8.3
检验配置
/usr/local/openresty/bin/openresty -t
启动
/usr/local/openresty/bin/openresty
停⽌
/usr/local/openresty/bin/openresty -s stop
重新加载配置
/usr/local/openresty/bin/openresty -s reload

  • 配置/lib/systemd/system/openresty.service,通过systemctl启动:

[Unit]
Description=openresty – high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/openresty/bin/openresty -c /usr/local/openresty/nginx/conf/nginx.conf
ExecReload=/usr/local/openresty/bin/openresty -s reload
ExecStop=/usr/local/openresty/bin/openresty -s stop
[Install]
WantedBy=multi-user.target

9.添加openresty.service后,使配置文件生效:

$ systemctl daemon-reload

10.使用systemctl管理openresty:

启动
$ systemctl start openresty
停⽌
$ systemctl stop openresty
重载配置
$ systemctl reload openresty
重启
$ systemctl restart openresty

到此这篇关于强大的 Web 应⽤服务器OpenResty安装(Nginx仓库) 的文章就介绍到这了,更多相关安装OpenResty内容请搜索悠久资源以前的文章或继续浏览下面的相关文章希望大家以后多多支持悠久资源!

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 Nginx服务器 强大的 Web 应⽤服务器OpenResty安装(Nginx仓库) https://www.u-9.cn/server/nginx/114266.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务