[nginx]编译安装openresty
2022/9/5 5:23:00
本文主要是介绍[nginx]编译安装openresty,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
前言
OpenResty是一个基于Nginx和Lua的高性能Web平台,其内部集成了大量精良的Lua库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。
版本信息
系统和应用 | 版本 |
---|---|
Debian | 11-amd64位 |
OpenResty | 1.21.4.1 |
步骤
- 下载源码包并解压
wget https://openresty.org/download/openresty-1.21.4.1.tar.gz tar xf openresty-1.21.4.1.tar.gz
- 编译
# apt安装依赖 apt install -y libpcre3-dev openssl libssl-dev libxml2-dev libgd-dev libxml2 libgeoip-dev libxslt-dev cd openresty-1.21.4.1 # 以下预编译参数和Nginx的编译参数基本一致 ./configure --prefix=/home/apps/openresty \ --with-threads \ --with-file-aio \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_xslt_module=dynamic \ --with-http_image_filter_module=dynamic \ --with-http_geoip_module=dynamic \ --with-http_sub_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_mp4_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_auth_request_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_degradation_module \ --with-http_slice_module \ --with-http_stub_status_module \ --with-stream_ssl_module \ --with-stream_realip_module \ --with-stream_geoip_module=dynamic \ --with-stream_ssl_preread_module \ --with-compat \ --with-pcre-jit gmake gmake install
- 启动OpenResty
/home/aps/openresty/bin/openresty
- 浏览器访问80端口测试
- (可选)验证无误后,将openresty的bin目录添加到系统环境变量PATH中
helloworld
- 编辑
/home/apps/openresty/nginx/conf/nginx.conf
, 找到监听80端口的server,增加以下路由
location = /test { default_type 'text/plain'; content_by_lua_block { ngx.say('Hello World') } }
- 热加载生效
openresty -s reload
- 测试
curl http://127.0.0.1/test
ngx.say
将数据作为响应体输出,返回给客户端,并在末尾加上一个回车符。
content_by_lua_block
的主要作用是在HTTP的内容处理阶段生成数据
参考
- OpenResty 官方中文站
这篇关于[nginx]编译安装openresty的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29fail2ban nginx
- 2024-03-18install nginx proxy manager
- 2024-01-2444从零开始用Rust编写nginx,命令行参数的设计与解析及说明
- 2024-01-22比Nginx更好用的Gateway!
- 2024-01-17nginx daemon off
- 2023-12-30Nginx Vhost Traffic Status 是什么意思-icode9专业技术文章分享
- 2023-12-26使用nginx搭建creates.io镜像(稀疏索引)
- 2023-11-18centos7编译安装Nginx教程。
- 2023-11-02nginx启动命令和停止命令
- 2023-10-25Centos7系统Nginx负载均衡如何安装和配置?