我是靠谱客的博主 背后雪碧,最近开发中收集的这篇文章主要介绍【Nginx】openresty-1.19.9.1 rpm包安装,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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

Lastest release

  • openresty-1.19.9.1.tar.gz   5.0MB   PGP   Changes - 6 August 2021

        不过二进制安装稍显复杂,这里就采用 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

最后

以上就是背后雪碧为你收集整理的【Nginx】openresty-1.19.9.1 rpm包安装的全部内容,希望文章能够帮你解决【Nginx】openresty-1.19.9.1 rpm包安装所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(44)

评论列表共有 0 条评论

立即
投稿
返回
顶部