基於centos7源碼編譯openresty

概述

  基於源碼構建openresty,爲後續編寫lua嵌入式腳本提供測試環境。OpenResty® 是一個基於 Nginx 與 Lua 的高性能 Web 平臺,其內部集成了大量精良的 Lua 庫、第三方模塊以及大多數的依賴項。用於方便地搭建可以處理超高併發、擴展性極高的動態 Web 應用、Web 服務和動態網關。html

環境:nginx

centos7 x86_64centos

openresty-1.15.8.1.tar.gz併發

下載

http://openresty.org/cn/curl

http://openresty.org/cn/download.html高併發

https://openresty.org/download/openresty-1.15.8.1.tar.gz性能

http://openresty.org/cn/components.html   ###lua給nginx擴展的lua插件,實現更多協議及應用的負載測試

依賴

注意:openresty是基於ningx上嵌入lua的解釋器支持插件的拓展ui

yum install -y gcc make pcre-devel openssl-devel zlib-devellua

tar xf openresty-1.15.8.1.tar.gz

編譯

[root@c_3 openresty-1.15.8.2]# ./configure --prefix=/opt/openresty

[root@c_3 openresty-1.15.8.2]# make -s -j2
==== Building LuaJIT 2.1.0-beta3 ====
==== Successfully built LuaJIT 2.1.0-beta3 ====

[root@c_3 openresty-1.15.8.2]#
[root@c_3 openresty-1.15.8.2]# make -s install
==== Building LuaJIT 2.1.0-beta3 ====
==== Successfully built LuaJIT 2.1.0-beta3 ====
==== Installing LuaJIT 2.1.0-beta3 to /opt/openresty/luajit ====
==== Successfully installed LuaJIT 2.1.0-beta3 to /opt/openresty/luajit ====

 

測試

[root@c_3 openresty]# ./bin/openresty -v
nginx version: openresty/1.15.8.2
[root@c_3 openresty]# ./bin/openresty -V ###默認編譯自動編譯的參數
nginx version: openresty/1.15.8.2

###nginx_lua.conf

worker_processes  1;
error_log logs/error.log;
events {
    worker_connections 1024;
}
http {
    server {
        listen 8080;
        location / {
            default_type text/html;
            content_by_lua_block {
                ngx.say("<p>hello, world</p>")
            }
        }
    }
}

測試配置文件及啓動服務

[root@c_3 openresty]# ./bin/openresty -c /opt/openresty/conf/nginx_lua.conf  -t ###openresty軟鏈接nginx/sbin/nginx
nginx: the configuration file /opt/openresty/conf/nginx_lua.conf syntax is ok
nginx: configuration file /opt/openresty/conf/nginx_lua.conf test is successful

[root@c_3 openresty]# ./bin/openresty -c /opt/openresty/conf/nginx_lua.conf ###啓動服務
[root@c_3 openresty]# ps -ef |grep nginx 
root      10398      1  0 04:28 ?        00:00:00 nginx: master process ./bin/openresty -
nobody    10399  10398  0 04:28 ?        00:00:00 nginx: worker process
root      10424      1  0 04:33 ?        00:00:00 nginx: master process ./bin/openresty -c /opt/openresty/conf/nginx_
lua.confnobody    10425  10424  0 04:33 ?        00:00:00 nginx: worker process
root      10427  10362  0 04:33 pts/1    00:00:00 grep --color=auto nginx
[root@c_3 openresty]# 
[root@c_3 openresty]# ss -lnt
State       Recv-Q Send-Q             Local Address:Port                            Peer Address:Port              
LISTEN      0      128                            *:8080                                       *:*                  
LISTEN      0      128                            *:80                                         *:*                  
LISTEN      0      128                            *:22                                         *:*                  
LISTEN      0      128                           :::2375                                      :::*                  
LISTEN      0      128                           :::22                                        :::*                  
[root@c_3 openresty]# curl 127.0.0.1:8080/   ###正常響應
<p>hello, world</p> 
相關文章
相關標籤/搜索