运维之OpenResty

2020-08-11  本文已影响0人  felixfeijs

运维之OpenResty

目录

OpenResty简单介绍

在win上安装OpenResty

在linux上安装OpenResty

  1. 安装依赖
    yum install pcre-devel openssl-devel gcc curl postgresql-devel
  2. 下载安装包
    wget -c https://openresty.org/download/openresty-1.15.8.1rc2.tar.gz
  3. 解压文件
    tar -zxvf openresty-1.15.8.1rc2.tar.gz
  4. 源码编译
//切换目录 
cd openresty-1.15.8.1rc2 
//开始安装 
./configure #或者下面,后面是参数 不写默认就行 
./configure --prefix=/usr/local/openresty/ --with-http_stub_status_module --with-luajit --without-http_redis2_module --with-http_iconv_module --with-http_postgres_module --with-stream gmake && gmake install
  1. 添加环境变量
  1. 配置生效
    source /etc/profile
  2. 添加仓库执行命令
yum install yum-utils
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
  1. 执行安装
    yum install openresty
  1. 配置nginx
user root;
  1. 启动nginx
    nginx -s reload
  1. 通过ip访问nginx,成功

在Docker上安装OpenResty

  1. 下载镜像
    docker pull openresty/openresty
  2. 启动镜像
    docker run -it -d --name openresty --privileged=true -p 80:80 openresty/openresty
  3. 创建宿主机nginx.conf
mkdir openresty  
mkdir conf
  1. 复制docker中的nginx.conf到宿主机
    docker cp openresty:/usr/local/openresty/nginx/conf/nginx.conf /usr/local/my-insall/openresty/conf
  2. 删除OpenResty容器
    docker stop id
    docker rm id
  3. 宿主机配置文件进行关联
    docker run -it -d -p 80:80 --name openresty --privileged=true --restart always \
    -v /usr/local/my-insall/openresty/conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf \
    -v /etc/localtime:/etc/localtime openresty/openresty
  4. 检查是否成功
    curl "http://127.0.01"
  5. openresty成功图示.png
上一篇 下一篇

猜你喜欢

热点阅读