OpenResty是一個基於 Nginx 與 Lua 的高性能 Web 平臺,其內部集成了大量精良的 Lua 庫、第三方模塊以及大多數的依賴項。用於方便地搭建可以處理超高併發、擴展性極高的動態 Web 應用、Web 服務和動態網關。
OpenResty 經過匯聚各類設計精良的 Nginx 模塊(主要由 OpenResty 團隊自主開發),從而將 Nginx 有效地變成一個強大的通用 Web 應用平臺。這樣,Web 開發人員和系統工程師能夠使用 Lua 腳本語言調動 Nginx 支持的各類 C 以及 Lua 模塊,快速構造出足以勝任 10K 乃至 1000K 以上單機併發鏈接的高性能 Web 應用系統。
OpenResty 的目標是讓你的Web服務直接跑在 Nginx 服務內部,充分利用 Nginx 的非阻塞 I/O 模型,不單單對 HTTP 客戶端請求,甚至於對遠程後端諸如 MySQL、PostgreSQL、Memcached 以及 Redis 等都進行一致的高性能響應。html
[root@web-001 ~]# wget https://openresty.org/download/openresty-1.9.15.1.tar.gz
您必須將這些庫 perl 5.6.1+
, libreadline
, libpcre
, libssl
安裝在您的電腦之中。 對於 Linux來講, 您須要確認使用 ldconfig
命令,讓其在您的系統環境路徑中能找到它們。nginx
推薦您使用 apt-get安裝如下的開發庫:web
apt-get install libreadline-dev libncurses5-dev libpcre3-dev \ libssl-dev perl make build-essential
推薦您使用yum安裝如下的開發庫:後端
yum install readline-devel pcre-devel openssl-devel gcc
[root@web-001 ~]# tar fxz openresty-1.9.15.1.tar.gz [root@web-001 ~]# cd openresty-1.9.15.1 [root@web-001 openresty-1.9.15.1]# ./configure [root@web-001 openresty-1.9.15.1]# make [root@web-001 openresty-1.9.15.1]# make install
注:默認, --prefix=/usr/local/openresty
程序會被安裝到/usr/local/openresty目錄。併發
[root@web-001 ~]# /usr/local/openresty/nginx/sbin/nginx
[root@web-001 ~]# ss -antp|grep nginx LISTEN 0 128 *:80 *:* users:(("nginx",10794,6),("nginx",10793,6))
[root@web-001 ~]# curl -I http://127.0.0.1 HTTP/1.1 200 OK Server: openresty/1.9.15.1 Date: Sat, 25 Jun 2016 23:03:55 GMT Content-Type: text/htmlContent-Length: 612 Last-Modified: Sat, 25 Jun 2016 23:03:29 GMT Connection: keep-alive ETag: "576f0dc1-264 "Accept-Ranges: bytes
[root@web-001 ~]# /usr/local/openresty/nginx/sbin/nginx -s stop
[root@web-001 ~]# echo PATH=$PATH:/usr/local/openresty/nginx/sbin/ >> /etc/profile [root@web-001 ~]# source /etc/profile
server_tokens off; #關閉版本顯示
注:吧上面內容放在http段便可,而後從新檢查語法以及重載便可curl
[root@web-001 ~]# nginx -t nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful