centos 安裝openresty

1. 安裝依賴的軟件包

/usr/bin/env: perl: No such file or directory出現(xiàn)這種錯誤可能是沒有安裝prel

yum install readline-devel pcre-devel openssl-devel gcc

2. 安裝openresty

-- 1. 下載openresty源碼: http://openresty.org/cn/download.html
$ wget https://openresty.org/download/openresty-1.9.7.4.tar.gz

-- 2. 解壓tar包
$ tar xzvf openresty-1.9.7.4.tar.gz

-- 3. 配置編譯選項,可以根據(jù)你的實際情況增加、減少相應的模塊
$ ./configure --prefix=/opt/openresty --with-luajit --without-http_redis2_module --with-http_iconv_module

-- 4. 編譯并安裝
$ make
$ make install 

3. HelloWorld

-- 1. 修改配置文件如下:
$ cat /opt/openresty/nginx/conf/nginx.conf
worker_processes  1;
error_log logs/error.log info;

events {
    worker_connections 1024;
}

http {
    server {
        listen 8003;

        location / {
            content_by_lua 'ngx.say("hello world.")';
        }
    }
}

-- 2. 啟動nginx
$ /opt/openresty/nginx/sbin/nginx

-- 3. 檢查nginx
$ curl http://127.0.0.1:8003/
hello world.

4. 性能測試

-- 1. 安裝壓力測試工具
$ yum install httpd-tools

-- 2. 測試
$ ab -c10 -n50000 http://localhost:8003/
...
Concurrency Level:      10
Time taken for tests:   2.825 seconds
Complete requests:      50000
Failed requests:        0
Write errors:           0
Total transferred:      8050000 bytes
HTML transferred:       650000 bytes
Requests per second:    17697.26 [#/sec] (mean)
Time per request:       0.565 [ms] (mean)
Time per request:       0.057 [ms] (mean, across all concurrent requests)
Transfer rate:          2782.48 [Kbytes/sec] received
...

ref

http://openresty.org/cn/installation.html
http://openresty.org/cn/getting-started.html
http://openresty.org/cn/using-luarocks.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、安裝準備 安裝OpenResty之前,您必須將這些庫 perl 5.6.1+, libreadline, li...
    kinglau閱讀 3,523評論 0 0
  • git[編輯]維基百科,自由的百科全書 git gitweb,git的一個Web界面。 原作者林納斯·托瓦茲 開發(fā)...
    半片殘楓閱讀 495評論 0 0
  • openresty安裝與簡單示例 @author 0597agentzhu 2016/6/10 OpenRest...
    云楓隨筆閱讀 4,093評論 0 4
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,554評論 19 139
  • 好想好想為你們寫一首歌。因為你們的出現(xiàn)讓我感覺世界那么美好。那么美好。 我遇到過在圖書館里自己的座位被我占用之后,...
    就是很帥htx閱讀 309評論 0 0

友情鏈接更多精彩內(nèi)容