Apisix安装

环境介绍

  • centos7虚拟机

详细步骤

  1. 安装etcd,具体如下:

    # 安装 etcd
    wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz
    tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
        cd etcd-v3.4.13-linux-amd64 && \
        sudo cp -a etcd etcdctl /usr/bin/
    
    # 添加 OpenResty 源
    sudo yum install yum-utils
    sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
    
    # 安装 OpenResty 和 编译工具
    sudo yum install -y openresty curl git gcc openresty-openssl111-devel unzip
    
    # 安装 LuaRocks
    curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
    
    # 开启 etcd server
    nohup etcd &
    
    # 重启机器之后启动etcd
    cd /usr/local/etcd-v3.4.13-linux-amd64
    nohup etcd &
    
  2. 安装apisix

    # 提前解决依赖问题
    # 安装epel源, luarocks 需要使用到.
    wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    rpm -ivh epel-release-latest-7.noarch.rpm
    
    # 添加OpenResty 的镜像源
    yum install yum-utils
    yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
    
    # 安装 OpenResty, etcd 和一些依赖工具【由于上一步已经安装etcd了,所以此处就不再安装了,好吧,其实是此处安装的etcd版本太低,apisix不支持,所以又重新安装】
    # yum install -y etcd openresty curl git gcc luarocks lua-devel
    yum install -y openresty curl git gcc luarocks lua-devel
    
    # 防火墙关闭
    systemctl stop firewalld.service
    systemctl disable firewalld.service
    
    # 关闭selinux
    setenforce 0
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    
    # 安装apisix
    yum install -y https://github.com/apache/apisix/releases/download/2.5/apisix-2.5-0.x86_64.rpm
    
    # 启动apisix
    apisix start
    # 如果使用的是tar.gz包安装的话,就是在解压目录下使用make run命令,详情可以查看apisix官方文档
    
    # 查看apisix的相关命令
    apisix --help
    
    # 查看服务是否启动
    # 查看进程或者监听端口9080
    ps aux|grep apisix
    netstat -lntp|grep 9080
    
    # 至此,apisix已经安装成功了
    
  3. 安装apisix-dashboard

    # 先安装依赖
    # node、npm
    wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz
    #解压部署
    tar xvf node-v12.16.1-linux-x64.tar.xz
    mv node-v12.16.1-linux-x64 /usr/local/node
    
    #配置环境变量
    echo 'PATH=/usr/local/node/bin/:$PATH' >> /etc/profile
    source /etc/profile
    
    #测试环境
    node --version
    npm --version
    

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pizF0BEY-1621424373105)(C:\Users\vince\AppData\Roaming\Typora\typora-user-images\image-20210516121453752.png)]

    # 安装yarn
    wget https://github.com/yarnpkg/yarn/releases/download/v1.22.4/yarn-v1.22.4.tar.gz
    
    #解压部署
    tar xvf yarn-v1.22.4.tar.gz
    mv yarn-v1.22.4 /usr/local/yarn
    
    #配置环境变量
    echo 'PATH=/usr/local/yarn/bin/:$PATH' >> /etc/profile
    source /etc/profile
    
    #测试环境
    yarn --version
    

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-4ojdUAOa-1621424373107)(C:\Users\vince\AppData\Roaming\Typora\typora-user-images\image-20210516121718137.png)]

    # 安装go
    ...
    
    #  把rpm包下载到本地 根据需求更新版本号,然后上传rpm包
    https://github.com/apache/apisix-dashboard/releases/download/v2.6/apisix-dashboard-2.6-0.x86_64.rpm
    # 安装
    yum localinstall apisix-dashboard-2.6-0.x86_64.rpm
    # 运行dashboard
    sudo nohup manager-api -p /usr/local/apisix/dashboard/ &
    

机器重启

  1. etcd

    # 重启机器之后启动etcd
    cd /usr/local/etcd-v3.4.13-linux-amd64
    nohup etcd &
    
  2. apisxi

    apisix start
    
  3. apisix-dashboard

    sudo nohup manager-api -p /usr/local/apisix/dashboard/ &
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值