【Nginx】openresty-1.19.9.1 rpm包安装

        官方提供了截至2021年8月6日,最新版本的二进制安装包下载。

Lastest release

        不过二进制安装稍显复杂,这里就采用 rpm 包来安装。官方也提供了 rpm 包下载和安装的详细步骤,这里增加了将包下载到本地保存的一个步骤。

// add the yum repo:
# wget https://openresty.org/package/centos/openresty.repo
# mv openresty.repo /etc/yum.repos.d/

// update the yum index:
# yum check-update

// download offline install packages:
# yum install -y openresty --downloadonly --downloaddir=./
# ls -ltr
total 2948
-rw-r--r-- 1 root root  167932 Mar 20  2020 openresty-pcre-8.44-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 1155616 Aug  6  2021 openresty-1.19.9.1-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 1630700 Mar 19 16:24 openresty-openssl111-1.1.1n-1.el7.x86_64.rpm
-rw-r--r-- 1 root root   55864 Apr  1 22:31 openresty-zlib-1.2.12-1.el7.x86_64.rpm\

// offline install
# yum install -y *.rpm
Loaded plugins: fastestmirror
Examining openresty-1.19.9.1-1.el7.x86_64.rpm: openresty-1.19.9.1-1.el7.x86_64
Marking openresty-1.19.9.1-1.el7.x86_64.rpm to be installed
Examining openresty-openssl111-1.1.1n-1.el7.x86_64.rpm: openresty-openssl111-1.1.1n-1.el7.x86_64
Marking openresty-openssl111-1.1.1n-1.el7.x86_64.rpm to be installed
Examining openresty-pcre-8.44-1.el7.x86_64.rpm: openresty-pcre-8.44-1.el7.x86_64
Marking openresty-pcre-8.44-1.el7.x86_64.rpm to be installed
Examining openresty-zlib-1.2.12-1.el7.x86_64.rpm: openresty-zlib-1.2.12-1.el7.x86_64
Marking openresty-zlib-1.2.12-1.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package openresty.x86_64 0:1.19.9.1-1.el7 will be installed
---> Package openresty-openssl111.x86_64 0:1.1.1n-1.el7 will be installed
---> Package openresty-pcre.x86_64 0:8.44-1.el7 will be installed
---> Package openresty-zlib.x86_64 0:1.2.12-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================================================================================================================
 Package                                                 Arch                                      Version                                            Repository                                                                    Size
=========================================================================================================================================================================================================================================
Installing:
 openresty                                               x86_64                                    1.19.9.1-1.el7                                     /openresty-1.19.9.1-1.el7.x86_64                                             3.5 M
 openresty-openssl111                                    x86_64                                    1.1.1n-1.el7                                       /openresty-openssl111-1.1.1n-1.el7.x86_64                                    4.1 M
 openresty-pcre                                          x86_64                                    8.44-1.el7                                         /openresty-pcre-8.44-1.el7.x86_64                                            453 k
 openresty-zlib                                          x86_64                                    1.2.12-1.el7                                       /openresty-zlib-1.2.12-1.el7.x86_64                                          114 k

Transaction Summary
=========================================================================================================================================================================================================================================
Install  4 Packages

Total size: 8.2 M
Installed size: 8.2 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : openresty-zlib-1.2.12-1.el7.x86_64                                                                                                                                                                                    1/4 
  Installing : openresty-openssl111-1.1.1n-1.el7.x86_64                                                                                                                                                                              2/4 
  Installing : openresty-pcre-8.44-1.el7.x86_64                                                                                                                                                                                      3/4 
  Installing : openresty-1.19.9.1-1.el7.x86_64                                                                                                                                                                                       4/4 
  Verifying  : openresty-pcre-8.44-1.el7.x86_64                                                                                                                                                                                      1/4 
  Verifying  : openresty-1.19.9.1-1.el7.x86_64                                                                                                                                                                                       2/4 
  Verifying  : openresty-zlib-1.2.12-1.el7.x86_64                                                                                                                                                                                    3/4 
  Verifying  : openresty-openssl111-1.1.1n-1.el7.x86_64                                                                                                                                                                              4/4 

Installed:
  openresty.x86_64 0:1.19.9.1-1.el7                     openresty-openssl111.x86_64 0:1.1.1n-1.el7                     openresty-pcre.x86_64 0:8.44-1.el7                     openresty-zlib.x86_64 0:1.2.12-1.el7                    

Complete!

启动openresty

# systemctl start openresty.service

# systemctl status openresty.service
● openresty.service - The OpenResty Application Platform
   Loaded: loaded (/usr/lib/systemd/system/openresty.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2022-04-15 10:27:55 EDT; 2min 39s ago
  Process: 3543 ExecStart=/usr/local/openresty/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 3541 ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
 Main PID: 3545 (nginx)
   CGroup: /system.slice/openresty.service
           ├─3545 nginx: master process /usr/local/openresty/nginx/sbin/nginx
           ├─3546 nginx: worker process
           ├─3547 nginx: worker process
           ├─3548 nginx: worker process
           └─3549 nginx: worker process

Apr 15 10:27:55 centos-7.9 systemd[1]: Starting The OpenResty Application Platform...
Apr 15 10:27:55 centos-7.9 nginx[3541]: nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
Apr 15 10:27:55 centos-7.9 nginx[3541]: nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
Apr 15 10:27:55 centos-7.9 systemd[1]: Started The OpenResty Application Platform.

可以发现 rpm 包安装的openresty的目录位于/usr/loca/openresty这个目录下。

修改/usr/local/openresty/nginx/conf/nginx.conf,在http{}块下面增加一个server{}块配置

    server {
        listen       8001;
        server_name  192.168.223.200;
        default_type text/html;

        location /test {
            content_by_lua_block {
                ngx.say("Hello World")
            }
        }
    }

重新加载nginx配置,或者直接重启openresty服务,即可测试访问。

# curl http://192.168.223.200:8001/test -i
HTTP/1.1 200 OK
Server: openresty
Date: Fri, 15 Apr 2022 14:33:13 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive

Hello World

参考:

http://openresty.org/cn/linux-packages.html#centos

https://blog.csdn.net/xzx4959/article/details/103879247

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cnskylee

技术分享我是认真的,期待您打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值