Openresty安裝

1. 安裝依賴的軟件包
yum install perl gcc kernel-devel
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. 配置編譯選項(xiàng),可以根據(jù)你的實(shí)際情況增加、減少相應(yīng)的模塊
$ ./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. 啟動(dòng)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
...
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

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