centos7部署OpenResty
  1m9rJBpbaLoS 2023年11月02日 46 0

一 OpenResty简介

OpenResty是基于Ngnix和Lua的高性能web平台,内部集成精良的LUa库、第三方模块、依赖项。用于方便搭建能够处理高并发、扩展性极高的动态web应用、web服务、动态网关。可以使用Lua脚本调用Ngnix支持的C以及Lua模块,快速构建10K~1000K单机并发连接的高性能web应用系统。OpenResty的目标是让web服务直接运行在Nginx服务内部,利用Ngnix的非阻塞IO模型,对HTTP客户端请求和后端DB进行一致的高性能响应。

OpenResty的出现可以说是颠覆了高性能服务端的开发模式。OpenResty实际上是Nginx+LuaJIT的完美组合。

centos7部署OpenResty_perl

二 安装依赖

[root@app-01 ~]# yum install pcre-devel openssl-devel gcc curl perl-devel perl-ExtUtils-Embed

三 下载软件并安装

下载地址:https://openresty.org/en/download.html

[root@app-01 ~]# wget https://openresty.org/download/openresty-1.19.9.1.tar.gz
[root@app-01 ~]# tar xf openresty-1.19.9.1.tar.gz
[root@app-01 ~]# cd openresty-1.19.9.1
[root@app-01 openresty-1.19.9.1]#./configure --prefix=/usr/local/openresty-1.19.9.1 --with-http_iconv_module --with-file-aio --with-poll_module --with-threads --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_stub_status_module --with-http_perl_module --with-stream_geoip_module --with-stream_realip_module --with-pcre --with-pcre-jit
[root@app-01 openresty-1.19.9.1]# make -j 4 && make install

四 查看安装的可执行文件

[root@app-01 ~]# ls -l /usr/local/openresty/bin/
total 164
-rwxr-xr-x 1 root root 19185 Nov 1 13:45 md2pod.pl
-rwxr-xr-x 1 root root 15994 Nov 1 13:45 nginx-xml2pod
lrwxrwxrwx 1 root root 37 Nov 1 13:45 openresty -> /usr/local/openresty/nginx/sbin/nginx
-rwxr-xr-x 1 root root 63510 Nov 1 13:45 opm
-rwxr-xr-x 1 root root 36623 Nov 1 13:45 resty
-rwxr-xr-x 1 root root 14957 Nov 1 13:45 restydoc
-rwxr-xr-x 1 root root 8873 Nov 1 13:45 restydoc-index

五 修改nginx配置文件

[root@app-01 ~]# vim /usr/local/openresty/nginx/conf/nginx.conf
server {
listen 8081;
server_name localhost;
}

六 配置环境变量

[root@app-01 ~]# ln -sv /usr/local/openresty-1.19.9.1/ /usr/local/openresty
‘/usr/local/openresty’ -> ‘/usr/local/openresty-1.19.9.1/’
[root@app-01 ~]# echo "export PATH=$PATH:/usr/local/openresty/bin" >> /etc/profile.d/openresty.sh

[root@app-01 ~]# . /etc/profild

[root@app-01 ~]# openresty -v

nginx version: openresty/1.19.9.1

七 添加openresty.service

[root@app-01 ~]# cat /lib/systemd/system/openresty.service
[Unit]
Description=openresty
After=network.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 quit

PrivateTmp=true
[Install]

WantedBy=multi-user.target

八 设置开机启动

[root@app-01 ~]# systemctl enable openresty
Created symlink from /etc/systemd/system/multi-user.target.wants/openresty.service to /usr/lib/systemd/system/openresty.service.
[root@app-01 ~]# systemctl start openresty
[root@app-01 ~]# systemctl status openresty
● openresty.service - openresty
Loaded: loaded (/usr/lib/systemd/system/openresty.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-11-01 14:09:39 CST; 3s ago
Process: 37679 ExecStart=/usr/local/openresty/bin/openresty -c /usr/local/openresty/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 37680 (openresty)
CGroup: /system.slice/openresty.service
├─37680 nginx: master process /usr/local/openresty/bin/openresty -c /usr/local/openresty/nginx/conf/nginx.conf
└─37681 nginx: worker process
Nov 01 14:09:39 bj2d-prod-artloop-app-03 systemd[1]: Starting openresty...

Nov 01 14:09:39 bj2d-prod-artloop-app-03 systemd[1]: Started openresty.

九 验证端口

[root@app-01 ~]# netstat -tnlp 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 42195/zabbix_agentd
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 922/php-fpm: master
tcp 0 0 127.0.0.1:9200 0.0.0.0:* LISTEN 15102/php-fpm: pool
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 846/nginx: master p
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 37680/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 786/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 846/nginx: master p
tcp6 0 0 :::10050 :::* LISTEN 42195/zabbix_agentd
tcp6 0 0 :::22 :::* LISTEN 786/sshd

 

 

 

 

 

 

 

 



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  RumN13MdT8PI   2023年11月13日   37   0   0 源码编译nginx
  lrdUmT56VgbP   2023年11月02日   73   0   0 gitnginxCentOS
  nQkVcpdWfLDr   2023年11月13日   30   0   0 cisedLua
  3OWcH55z3bwR   2023年11月02日   84   0   0 gitphpnginx
1m9rJBpbaLoS