centos安装OpenResty api 网关 Orange

OpenResty api网关设计,主要涉及api网关介绍、openresty api网关 请求路由(路由判断、路由重写、服务判断、限流)、授权验证(统一认证)、动态Upstream 以及这三部分理论简单实现的Api网关和Api网关admin。

安装依赖

yum -y install libuuid-devel pcre-devel openssl-devel gcc-c++ wget perl-Time-HiRes perl-Digest-MD5

编译安装openresty

https://openresty.org/cn/down...

wget https://openresty.org/download/openresty-1.13.6.1.tar.gz
tar xf openresty-1.13.6.1.tar.gz 
cd openresty-1.13.6.1
./configure  --prefix=/usr/local/openresty --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module
gmake && gmake install

yum 安装openresty

http://openresty.org/cn/linux...

sudo yum install yum-utils -y
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo 
sudo yum install openresty -y
sudo yum install -y openresty-resty

luarocks安装

https://luarocks.org/

wget https://luarocks.org/releases/luarocks-2.4.1.tar.gz
cd luarocks-2.4.1/
./configure --prefix=/usr/local/openresty/luajit \
    --with-lua=/usr/local/openresty/luajit/ \
    --lua-suffix=jit \
    --with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1
make build
# 安装需要root权限
sudo make install

环境变量设置

cat /etc/profile.d/openresty.sh 
export OPENRESTY_HOME=/usr/local/openresty
export NGINX_HOME=$OPENRESTY_HOME/nginx
export PATH=$OPENRESTY_HOME/bin:$NGINX_HOME/sbin:$PATH
source /etc/profile

mariadb安装

https://downloads.mariadb.org...

rpm -e mysql-*
rpm -qa | grep mariadb
yum remove mysql mysql-server mysql-libs compat-mysql51
vi /etc/yum.repos.d/MariaDB.repo
 
# MariaDB 10.4 CentOS repository list - created 2019-09-28 03:16 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
yum -y install MariaDB-server
 
mysql_secure_installation
首先是设置密码,会提示先输入密码
 
Enter current password for root (enter for none):<–初次运行直接回车
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车(后面授权配置)
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车 
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
 
 
mysql -uroot -p
CREATE USER 'orange'@'%' IDENTIFIED BY 'orange';
 
GRANT ALL PRIVILEGES ON orange.* TO 'orange'@'%';
FLUSH PRIVILEGES;

安装lor

yum install -y git
git clone https://github.com/sumory/lor.git
cd lor
make install

启动并配置 orange 服务

参考:https://github.com/orlabs/ora...

service iptables stop
chkconfig iptables off
git clone https://github.com/sumory/orange.git
cd orange
// orange 根目录  
luarocks install luafilesystem
luarocks install luasocket
luarocks install lrandom
// 安装 orange 依赖包  
opm --install-dir=./ get zhangbao0325/orangelib  
//配置文件
cd conf
cp orange.conf.example orange.conf
cp nginx.conf.example nginx.conf
cd install/
mysql -u orange -porange -h 127.0.0.1  orange < orange-v0.6.2.sql

你可能感兴趣的:(openresty)