CentOS7上OpenResty安裝


1,OpenResty安裝

  • 通過repl源安裝:
sudo yum-config-manager --add-repo https://openresty.org/yum/cn/centos/OpenResty.repo
sudo yum install openresty
  • 通過rpm包安裝:

https://copr-be.cloud.fedoraproject.org/results/openresty/openresty/epel-7-x86_64/依次下載下面這幾個rpm包:

openresty-1.13.6.2-1.el7.centos.x86_64.rpm
openresty-openssl-1.1.0h-3.el7.centos.x86_64.rpm
openresty-zlib-1.2.11-3.el7.centos.x86_64.rpm
openresty-pcre-8.42-1.el7.centos.x86_64.rpm

然后執行rpm -ivh openresty*.rpm即可安裝

  • 通過源碼安裝:

先安裝依賴庫:

$ yum install readline-devel pcre-devel openssl-devel perl

下載源碼包解壓編譯

$ wget https://openresty.org/download/openresty-1.13.6.2.tar.gz
$ tar zxvf openresty-1.13.6.2.tar.gz
$ cd openresty-1.13.6.2
$ ./configure --prefix=/usr/local/openresty --with-luajit --with-http_iconv_module
$ make 
$ make install

將openresty加入環境變量:

export PATH=$PATH:/usr/local/openresty/nginx/sbin 

2,運行與壓測

創建工作目錄並在指定路徑下運行:

$ mkdir -p /data/openresty  /data/openresty/logs  /data/openresty/conf
$ cp /usr/local/openresty/conf/nginx.conf /data/openresty/conf/
編輯配置文件,添加一個測試接口
$ vi nginx.conf 
location / {
    default_type text/html;
    content_by_lua_block {
        ngx.say("test................")
    }
} 
運行
$ nginx -p /data/openresty

測試接口:

$ curl localhost:8080/
test................

ab並發壓力測試:

如果沒有安裝ab工具,則先執行yum -y install httpd-tools安裝

測試之前還要檢查一下系統參數:

如果ulimit -n返回的是1024的話,則執行ulimit -n 30000 ,如果要徹底修改,則按如下操作:

$ vi /etc/security/limits.conf
在最后加入
* soft nofile 4096
* hard nofile 4096

修改完成之后進行壓測:

$ ab -c1000 -n10000 localhost:8080/
  ......

參考鏈接:
http://www.cnblogs.com/myvic/p/7703973.html

https://blog.csdn.net/fdipzone/article/details/34588803


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM