<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 概述 OpenResty 是一個基于 Nginx 的全功能 Web 平臺,它集成了大量精心設計的 Nginx 模塊,以及大量的 Lua 庫。在使用 OpenResty 時,有兩種主要的包管理工具:opm 和 LuaRocks。 ## OPM OPM(OpenResty Package Manager)是 OpenResty 官方提供的包管理工具,可以用來從中心 OPM 包服務器上面安裝社區貢獻的第三方模塊。專門用于安裝和管理 OpenResty 的 Lua 模塊。它是官方推薦使用的工具,因為它確保了模塊與 OpenResty 的兼容性,并優化了性能,在你安裝好 OpenResty 之后,就可以直接使用。 顯示命令幫助 ``` # opm --help opm [options] command package... Options: -h --help Print this help. --install-dir=PATH Install into the specified PATH directory instead of the system-wide OpenResty installation tree containing this tool. --cwd Install into the current working directory under ./resty_modules/ instead of the system-wide OpenResty installation tree containing this tool. Commands: build Build from the current working directory a package tarball ready for uploading to the server. clean ARGUMENT... Do clean-up work. Currently the valid argument is "dist", which cleans up the temporary files and directories created by the "build" command. info PACKAGE... Output the detailed information (or meta data) about the specified packages. Short package names like "lua-resty-lock" are acceptable. get PACKAGE... Fetch and install the specified packages. Fully qualified package names like "openresty/lua-resty-lock" are required. One can also specify a version constraint like "=0.05" and ">=0.01". list List all the installed packages. Both the package names and versions are displayed. remove PACKAGE... Remove (or uninstall) the specified packages. Short package names like "lua-resty-lock" are acceptable. search QUERY... Search on the server for packages matching the user queries in their names or abstracts. Multiple queries can be specified and they must fulfilled at the same time. server-build Build a final package tarball ready for distribution on the server. This command is usually used by the server to verify the uploaded package tarball. update Update all the installed packages to their latest version from the server. upgrade PACKAGE... Upgrade the packages specified by names to the latest version from the server. Short package names like "lua-resty-lock" are acceptable. upload Upload the package tarball to the server. This command always invokes the build command automatically right before uploading. For bug reporting instructions, please see: <https://openresty.org/en/community.html> Copyright (C) Yichun Zhang (agentzh). All rights reserved. ``` 通過`opm search [包名] `搜索包名和包的簡介 ``` # opm search lua-resty-http aptise/peter_sslers-lua-resty openresty ssl certificate routines for peter_sslers SSL Certificate manager aptise/lua-resty-peter_sslers openresty ssl certificate routines for peter_sslers SSL Certificate manager .... tomas/lua-resty-elasticsearch ElasticSearch client for OpenResty / ngx_lua. agentzh/lua-resty-http Lua HTTP client cosocket driver for OpenResty/ngx_lua ``` 通過`opm get [包名] `安裝擴展包 ``` # opm get ledgetech/lua-resty-http * Fetching ledgetech/lua-resty-http Downloading https://opm.openresty.org/api/pkg/tarball/ledgetech/lua-resty-http-0.17.1.opm.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 20622 100 20622 0 0 28133 0 --:--:-- --:--:-- --:--:-- 28095 Package ledgetech/lua-resty-http 0.17.1 installed successfully under /usr/local/openresty/site/ . ``` 通過`opm info [包名] `查看已安裝包的詳細信息 ``` # opm info lua-resty-http Name : lua-resty-http Version : 0.17.1 Abstract : Lua HTTP client cosocket driver for OpenResty/ngx_lua Author : James Hurst Account : ledgetech Code Repo : https://github.com/ledgetech/lua-resty-http License : BSD 2-Clause "Simplified" or "FreeBSD" license Original Work : yes ``` 通過`opm list`查看已經安裝的包列表 ``` # opm list agentzh/lua-resty-http 0.09 ``` 通過`opm upgrade [包名]`包升級 ``` # opm upgrade lua-resty-http * Fetching agentzh/lua-resty-http > 0.09 Package agentzh/lua-resty-http 0.09 is already the latest version. ``` 通過`opm remove [包名]`移除已經安裝的包 ``` # opm remove lua-resty-http Package agentzh/lua-resty-http 0.09 removed successfully. ``` 安裝包存儲位置 ``` cd /usr/local/openresty/site/lualib/resty # ls http.lua http_headers.lua ``` ### 使用 lua-resty-http 是一個基于OpenResty的HTTP客戶端庫,用于在Lua中進行HTTP請求和響應的處理。 `openresty.tinywan.com.conf`配置文件 ``` server { listen 80; server_name openresty.tinywan.com; location /lua_http_test { default_type "text/html"; lua_code_cache off; content_by_lua_file conf/lua/lua_http_test.lua; } } ``` `lua_http_test.lua` 腳本 ``` local httpc = require("resty.http").new() -- Single-shot requests use the `request_uri` interface. local res, err = httpc:request_uri("https://www.workerman.net/u/Tinywan", { method = "GET", body = "name=Tinywan&age=24", headers = { ["Content-Type"] = "application/x-www-form-urlencoded", }, ssl_verify = false, }) if not res then ngx.log(ngx.ERR, "request failed: ", err) return end local status = res.status local length = res.headers["Content-Length"] local body = res.body ngx.say(res.body) ``` 通過curl腳本測試請求打印結果 ```html $ curl -i http://openresty.tinywan.com/lua_http_test HTTP/1.1 200 OK Server: openresty/1.17.8.2 Date: Wed, 17 Jul 2024 09:42:10 GMT Content-Type: text/html; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Vary: Accept-Encoding <!doctype html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="shortcut icon" href="/favicon.ico" /> <link href="https://cdn.workerman.net/css/bootstrap.min.css?v=20211126" rel="stylesheet"> <link href="https://cdn.workerman.net/css/main.css?v=20240705" rel="stylesheet"> <script src="https://cdn.workerman.net/js/jquery.min.js"></script> <script src="https://cdn.workerman.net/js/bootstrap.min.js?v=20211126"></script> <script src="https://cdn.workerman.net/js/functions.js?v=20220507"></script> <script type="text/javascript" charset="UTF-8" src="https://cdn.wwads.cn/js/makemoney.js" async></script> <title>Tinywan的主頁-分享-workerman社區</title> </head> ... </body> </html> ``` ## LuaRocks LuaRocks 是一個通用的 Lua 模塊管理工具,可以用來安裝 Lua 模塊。然而,使用 luarocks 與 OpenResty 并不是官方推薦的方式,因為 luarocks 安裝的模塊可能會阻塞 OpenResty 的事件循環,導致性能下降。 詳細使用請看這里 [Openresty如何使用lualocks包管理器安裝使用Lua包](https://mp.weixin.qq.com/s/8fVUKW53vG8E3v8aOX_lWw)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看