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

posted @ 2019-05-16 22:55  堕落门徒  阅读(1890)  评论(0编辑  收藏  举报