优秀的编程知识分享平台

网站首页 > 技术文章 正文

orange(1)0.8.0版 网关安装步骤(及开发生产环境创建)

nanyue 2024-08-22 17:28:15 技术文章 6 ℃

进行以下操作之前先详细阅读github上的说明参见Github官方说明,可以避免很多麻烦。

orange网关必要软件

  • openresty
  • openresty-resty resty命令行工具
  • mysql
  • LuaRocks Lua 模块的安装和部署工具,类似nodeJs的npm
  • lor 框架是lua的web开发框架

1. 安装openresty

1.1 安装辅助工具

yum install yum-utils

一直报错404,找不到资源,更新yum镜像源

# 先清理
yum clean all
# 再更新
yum update

注意:因为需要在将stub_status_module编译进openresty,所以不能直接yum install安装

[root@localhost /]#yum -y install libuuid-devel pcre-devel openssl-devel gcc-c++ wget
...
[root@localhost /]# cd opt/
[root@localhost opt]# mkdir openresty
[root@localhost opt]# cd openresty/
[root@localhost openresty]#

1.2 安装openresty

访问openresty官网找到最新版本的gz包链接 openresty官网

[root@localhost openresty]#
[root@localhost openresty]# wget https://openresty.org/download/openresty-1.15.8.2.tar.gz
--2019-10-24 10:31:03--  https://openresty.org/download/openresty-1.15.8.2.tar.gz
Resolving openresty.org (openresty.org)... 182.92.4.22
Connecting to openresty.org (openresty.org)|182.92.4.22|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4906176 (4.7M) [application/x-gzip]
Saving to: ‘openresty-1.15.8.2.tar.gz’
100%[======================================================================================================================================================================================>] 4,906,176   1.82MB/s   in 2.6s
2019-10-24 10:31:07 (1.82 MB/s) - ‘openresty-1.15.8.2.tar.gz’ saved [4906176/4906176]
[root@localhost openresty]# ll
total 4792
-rw-rw-r--. 1 root root 4906176 Sep  8 01:46 openresty-1.15.8.2.tar.gz
[root@localhost openresty]#
# 解压缩
[root@localhost openresty]# tar -zxf openresty-1.15.8.2.tar.gz
[root@localhost openresty]#
# 配置
[root@localhost openresty]# cd openresty-1.15.8.2
[root@localhost openresty-1.15.8.2]#
[root@localhost openresty-1.15.8.2]# ll
total 104
drwxrwxr-x. 46 justin 1003  4096 Aug 29 01:33 bundle
-rwxrwxr-x.  1 justin 1003 52432 Aug 29 01:32 configure
-rw-rw-r--.  1 justin 1003 22924 Aug 29 01:32 COPYRIGHT
drwxrwxr-x.  2 justin 1003  4096 Aug 29 01:32 patches
-rw-rw-r--.  1 justin 1003  4689 Aug 29 01:32 README.markdown
-rw-rw-r--.  1 justin 1003  8972 Aug 29 01:32 README-windows.txt
drwxrwxr-x.  2 justin 1003    50 Aug 29 01:32 util
[root@localhost openresty-1.15.8.2]#
[root@localhost openresty-1.15.8.2]# ./configure --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module
platform: linux (linux)
cp -rp bundle/ build
cd build
cd LuaJIT-2.1-20190507
INFO: found -msse4.2 in cc.
gmake TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT -DLUAJIT_ENABLE_GC64 -msse4.2' CC=cc PREFIX=/usr/local/openresty/luajit
==== Building LuaJIT 2.1.0-beta3 ====
gmake -C src
...
  nginx http scgi temporary files: "scgi_temp"

cd ../..
Type the following commands to build and install:
    gmake
    gmake install
[root@localhost openresty-1.15.8.2]#
# 编译安装
[root@localhost openresty-1.15.8.2]# gmake && gmake install
...
# 建立软连接,开机自启动
[root@localhost openresty-1.15.8.2]#
[root@localhost openresty-1.15.8.2]# ln -s /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx
[root@localhost openresty-1.15.8.2]#
[root@localhost openresty-1.15.8.2]# ln -s /usr/local/openresty/nginx/sbin/nginx /usr/bin/openresty
[root@localhost openresty-1.15.8.2]# nginx -v
nginx version: openresty/1.15.8.2
[root@localhost openresty-1.15.8.2]#

1.3 启动openresty

[root@localhost bin]# openresty
[root@localhost bin]# ps -ef|grep openresty
root      5239     1  0 11:36 ?        00:00:00 nginx: master process openresty
root      5242  2443  0 11:36 pts/0    00:00:00 grep --color=auto openresty
[root@localhost bin]#

2. 安装resty命令行工具

[root@localhost bin]# yum install openresty-resty

orange命令行工具, 依赖resty命令

3. 安装mysql, 初始化orange数据库

3.1 下载mysql安装包,创建mysql账号

[root@localhost /]# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
# 解压
[root@localhost opt]# tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
...
[root@localhost opt]# cp mysql-8.0.18-linux-glibc2.12-x86_64 /usr/local/mysql -r
# 添加msyql用户组
[root@localhost opt]# groupadd mysql
# 添加mysql用户
[root@localhost opt]# useradd -r -g mysql mysql
# 禁止msyql用户登录主机
[root@localhost opt]# usermod -s /bin/false mysql
[root@localhost opt]#

3.2 安装mysql服务

[root@localhost opt]# cd /usr/local/mysql/
[root@localhost mysql]# ls
bin  docs  include  lib  LICENSE  LICENSE.router  man  README  README.router  run  share  support-files  var
[root@localhost mysql]# chown -R mysql:mysql ./
[root@localhost mysql]#

3.3 mysql5.7版本之后的方式初始化数据库

root@localhost mysql]# cd /usr/local/mysql/bin
[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
2019-10-24T16:44:24.044262Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2019-10-24T16:44:24.044719Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.18) initializing of server in progress as process 6013
2019-10-24T16:44:30.851231Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ********
[root@localhost bin]#

记住root账号的密码:********

3.4 编辑mysql配置文件 /etc/my.cnf

[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[client]
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock

[mysqld_safe]
log-error=/usr/local/mysql/data/log/mysqld.log
pid-file=/var/run/msyqld/mysqld.pid
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock
#
# include all files from the config directory
#
# !includedir /etc/my.cnf.d

添加mysql账号访问权限

chown -R mysql:mysql /usr/local/mysql

3.5 设置mysql开机自启动

[root@localhost support-files]# pwd
/usr/local/mysql/support-files
[root@localhost support-files]# ls
mysqld_multi.server  mysql-log-rotate  mysql.server
[root@localhost support-files]#
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]#

3.6 启动mysql

[root@localhost log]# service mysqld start
Starting MySQL.. SUCCESS!
[root@localhost log]#
[root@localhost log]# mysql -u root -p
-bash: /usr/bin/mysql: No such file or directory
[root@localhost log]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
[root@localhost log]#

3.7 访问mysql修改密码

mysql>
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password=PASSWORD('123456');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD('123456')' at line 1
# 必须用alter命令来修改密码
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.09 sec)
# 设定永不过期
mysql> alter user 'root'@'localhost' password expire never;
Query OK, 0 rows affected (0.07 sec)
# 刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.07 sec)
mysql>
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql>

mysql 安装完成.

3.8 初始化orange数据库

mysql> CREATE DATABASE orange CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected, 2 warnings (0.08 sec)

mysql> CREATE USER 'orange'@'%' IDENTIFIED BY 'orange';
Query OK, 0 rows affected (0.08 sec)

mysql> GRANT ALL PRIVILEGES ON orange.* TO 'orange'@'%';
Query OK, 0 rows affected (0.09 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.06 sec)

mysql>
  • 下载orange数据库脚本github地址,导入mysql
[root@localhost opt]# mysql -u root -p --database orange <./orange-v0.8.0.sql

4. 安装lor框架

lor框架是lua的web开发框架,类似于node.js的express框架,主要用于web界面dashboard

[root@localhost ~]# yum install -y git
...
[root@localhost ~]# cd /opt/
[root@localhost opt]#
[root@localhost opt]# ls
containerd  mysql-8.0.18-linux-glibc2.12-x86_64  mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz  openresty  orange-v0.8.0.sql
[root@localhost opt]# git clone https://github.com/sumory/lor.git
Cloning into 'lor'...
remote: Enumerating objects: 30, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 1759 (delta 5), reused 17 (delta 5), pack-reused 1729
Receiving objects: 100% (1759/1759), 355.55 KiB | 206.00 KiB/s, done.
Resolving deltas: 100% (911/911), done.
[root@localhost opt]#
[root@localhost opt]# ls
containerd  lor  mysql-8.0.18-linux-glibc2.12-x86_64  mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz  openresty  orange-v0.8.0.sql
[root@localhost opt]# cd lor/
[root@localhost lor]#
[root@localhost lor]# pwd
/opt/lor
[root@localhost lor]# make install
install lor runtime files to /usr/local/lor
lor runtime files installed.
install lord cli to /usr/local/bin/
lord cli installed.
lor framework installed successfully.

5. 安装LuaRocks

luarocks是一个lua的包管理器(类似于nodejs的npm),基于lua语言开发,提供命令行的方式管理lua包依赖,安装第三方lua包。 下载luarocks源码

5.1 下载luarocks

# 下载
[root@localhost luarocks-3.1.3]# wget https://luarocks.github.io/luarocks/releases/luarocks-3.1.3.tar.gz
[root@localhost luarocks-3.1.3]# tar zxvf luarocks-3.1.3.tar.gz
[root@localhost luarocks-3.1.3]# cd luarocks-3.1.3
# 查看文件
[root@localhost luarocks-3.1.3]# ll
total 100
drwxr-xr-x. 2 justin users  4096 Jun  7 03:46 binary
drwxrwxr-x. 2 root   root     63 Oct 25 23:40 build
-rw-r--r--. 1 justin users 10403 Jun  7 03:46 CHANGELOG.md
-rw-r--r--. 1 justin users  3152 Jun  7 03:46 CODE_OF_CONDUCT.md
-rw-r--r--. 1 justin users   143 Jun  7 03:46 config.ld
-rw-rw-r--. 1 root   root    352 Oct 25 23:39 config.unix
-rwxr-xr-x. 1 justin users 14119 Jun  7 03:46 configure
-rw-r--r--. 1 justin users  1060 Jun  7 03:46 COPYING
-rw-r--r--. 1 justin users  6114 Jun  7 03:46 GNUmakefile
-rwxr-xr-x. 1 root   root    549 Oct 25 23:40 lua
drwxr-xr-x. 3 root   root     16 Oct 25 23:40 lua_modules
-rwxrwxr-x. 1 root   root    275 Oct 25 23:40 luarocks
-rw-r--r--. 1 justin users  1120 Jun  7 03:46 luarocks-3.1.3-1.rockspec
-rwxrwxr-x. 1 root   root    281 Oct 25 23:40 luarocks-admin
-rw-r--r--. 1 justin users    78 Jun  7 03:46 Makefile
-rwxr-xr-x. 1 justin users   443 Jun  7 03:46 mergerelease
-rwxr-xr-x. 1 justin users  4930 Jun  7 03:46 publishrelease
-rw-r--r--. 1 justin users  1880 Jun  7 03:46 README.md
-rwxr-xr-x. 1 justin users  1000 Jun  7 03:46 smoke_test.sh
drwxr-xr-x. 4 justin users  4096 Jun  7 03:46 spec
drwxr-xr-x. 4 justin users    31 Jun  7 03:46 src
[root@localhost luarocks-3.1.3]#
# 优先查看README.md了解安装流程

可以看到有 configure,Markfile 文件,通常软件源码安装为三个步骤

配置(configure) 编译(make) 安装(make install) 参考:源码安装

5.2 源码安装luarocks

参考:Lua包管理工具luarocks安装

# 查看配置信息
[root@localhost luarocks-3.1.3]# ./configure --help
# 有两个重要参数  
# 设置luarocks的安装路径,默认 /usr/local
# --prefix 设置prefix会自动将Luarocks以及往后使用Luarocks安装的Lua包,LuaC包都安装到Luarocks安装路径下的相应位置,否则相关的包文件散落在文件系统中,显得杂乱不便于管理,如果所安装的Lua模板包含bin文件,则会自动安装到此目录下的bin路径,与Luarocks可执行文件同一路径,更便于管理、使用。
  --prefix=PREFIX              Directory where LuaRocks should be installed
                               [/usr/local]
# 指定luarocks依赖的lua安装路径
  --with-lua=LUA_DIR           Use Lua from given directory. [LUA_BINDIR/..]

5.2 配置luarocks

[root@localhost luarocks-3.1.3]#
[root@localhost luarocks-3.1.3]# ./configure --prefix=/usr/local/luarocks --with-lua=/usr/local/luajit

Configuring LuaRocks version 3.1.3...

Lua version detected: 5.1
Lua interpreter found: /usr/local/luajit/bin/luajit
lua.h found: /usr/local/luajit/include/luajit-2.0/lua.h
unzip found in PATH: /usr/bin

Done configuring.

LuaRocks will be installed at......: /usr/local/luarocks
LuaRocks will install rocks at.....: /usr/local/luarocks
LuaRocks configuration directory...: /usr/local/luarocks/etc/luarocks
Using Lua from.....................: /usr/local/luajit

* Type make and make install:
  to install to /usr/local/luarocks as usual.
* Type make bootstrap:
  to install LuaRocks into /usr/local/luarocks as a rock.

5.3 编译 安装luarocks

  • make && make install 编译安装 顺序执行
[root@localhost luarocks-3.1.3]# make && make install
mkdir -p "build"
rm -f src/luarocks/core/hardcoded.lua
echo "#!/bin/sh" > luarocks
echo "unset LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4" >> luarocks
echo 'LUAROCKS_SYSCONFDIR="/usr/local/luarocks/etc/luarocks" LUA_PATH="/opt/luarocks-3.1.3/src/?.lua;;" exec "/usr/local/luajit/bin/luajit" "/opt/luarocks-3.1.3/src/bin/luarocks" --project-tree="/opt/luarocks-3.1.3/lua_modules" "$@"' >> luarocks
chmod +rx ./luarocks
./luarocks init

Initializing project 'luarocks-3.1.3' for Lua 5.1 ...
-----------------------------------------------------

Checking your Lua installation ...
Adding entries to .gitignore ...
Preparing ./.luarocks/ ...
Wrote .luarocks/config-5.1.lua
Preparing ./lua_modules/ ...
./luarocks already exists. Not overwriting it!
Preparing ./lua for version 5.1...
cp ./build/config-5.1.lua .luarocks/config-5.1.lua
rm -f src/luarocks/core/hardcoded.lua
echo "#!/bin/sh" > luarocks-admin
echo "unset LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4" >> luarocks-admin
echo 'LUAROCKS_SYSCONFDIR="/usr/local/luarocks/etc/luarocks" LUA_PATH="/opt/luarocks-3.1.3/src/?.lua;;" exec "/usr/local/luajit/bin/luajit" "/opt/luarocks-3.1.3/src/bin/luarocks-admin" --project-tree="/opt/luarocks-3.1.3/lua_modules" "$@"' >> luarocks-admin
chmod +rx ./luarocks-admin
mkdir -p "build"
(printf '#!/usr/local/luajit/bin/luajit\n'\
'package.loaded["luarocks.core.hardcoded"] = { '\
"$([ -n "" ] && printf 'FORCE_CONFIG = true, ')"\
'SYSCONFDIR = [[/usr/local/luarocks/etc/luarocks]] }\n'\
'package.path=[[/usr/local/luarocks/share/lua/5.1/?.lua;]] .. package.path\n'; \
tail -n +2 src/bin/luarocks \
)> "build/luarocks"
mkdir -p "build"
(printf '#!/usr/local/luajit/bin/luajit\n'\
'package.loaded["luarocks.core.hardcoded"] = { '\
"$([ -n "" ] && printf 'FORCE_CONFIG = true, ')"\
'SYSCONFDIR = [[/usr/local/luarocks/etc/luarocks]] }\n'\
'package.path=[[/usr/local/luarocks/share/lua/5.1/?.lua;]] .. package.path\n'; \
tail -n +2 src/bin/luarocks-admin \
)> "build/luarocks-admin"
mkdir -p "/usr/local/luarocks/bin"
install "build/luarocks" "/usr/local/luarocks/bin/luarocks"
mkdir -p "/usr/local/luarocks/bin"
install "build/luarocks-admin" "/usr/local/luarocks/bin/luarocks-admin"
mkdir -p "/usr/local/luarocks/etc/luarocks"
install -m 644 "build/config-5.1.lua" "/usr/local/luarocks/etc/luarocks/config-5.1.lua"
[root@localhost luarocks-3.1.3]#
[root@localhost luarocks-3.1.3]# luarocks
LuaRocks 3.1.3, the Lua package manager
...
CONFIGURATION
	Lua version: 5.1
	LuaJIT version: 2.0.5

	Configuration files:
		System  : /usr/local/luarocks/etc/luarocks/config-5.1.lua (ok)
		User    : /root/.luarocks/config-5.1.lua (not found)
		Project : /opt/luarocks-3.1.3/./.luarocks/config-5.1.lua (ok)

	Rocks trees in use:
		/opt/luarocks-3.1.3/./lua_modules ("project")
		/root/.luarocks ("user")
		/usr/local/luarocks ("system")

luarocks已经成功安装,指定的lua是 luajit 2.0.5

6. 安装orange

6.1 clone下载orange源码

[root@localhost opt]#
[root@localhost opt]# git clone https://github.com/sumory/orange.git
Cloning into 'orange'...
remote: Enumerating objects: 46, done.
remote: Counting objects: 100% (46/46), done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 4436 (delta 17), reused 28 (delta 11), pack-reused 4390
Receiving objects: 100% (4436/4436), 2.84 MiB | 562.00 KiB/s, done.
Resolving deltas: 100% (2903/2903), done.
[root@localhost opt]# ll
total 492080
drwx--x--x.  4 root root        26 Sep 11 14:14 containerd
drwxrwxr-x.  8 root root      4096 Oct 25 04:59 lor
drwxrwxr-x. 11 root root      4096 Oct 24 12:38 mysql-8.0.18-linux-glibc2.12-x86_64
-rw-rw-r--.  1 root root 503854832 Sep 22 10:33 mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
drwxrwxr-x.  3 root root        63 Oct 24 10:32 openresty
drwxrwxr-x. 13 root root      4096 Oct 25 05:01 orange
-rw-r--r--.  1 root root     18157 Oct 24 13:21 orange-v0.8.0.sql
[root@localhost opt]#

6.2 创建orange开发环境配置

cd orangemake dev

[root@localhost orange]# make dev
luarocks install rockspec/orange-master-1.0-0.rockspec --tree=deps --only-deps --local
Missing dependencies for orange-master 1.0-0:
   luafilesystem 1.7.0-2 (not installed)
   penlight 1.5.4-1 (not installed)
   lrandom 20180729-1 (not installed)
   luacrypto 0.3.2-2 (not installed)
   luasocket 3.0rc1-2 (not installed)
   lua-resty-http 0.13-0 (not installed)
   lua-resty-kafka 0.06-0 (not installed)
   lua-resty-dns-client 1.0.0-1 (not installed)
   lua-resty-jwt 0.2.0-0 (not installed)

...
install conf/nginx.conf.example conf/nginx.conf
install conf/orange.conf.example conf/orange.conf
install install/orange-v0.8.0.sql conf/orange-v0.8.0.sql
[root@localhost orange]#

安装完orange依赖包,及配置文件自动生成.

6.3 配置文件 conf/orange.conf

[root@localhost conf]#
[root@localhost conf]# pwd
/opt/orange/conf
[root@localhost conf]# ll
total 16
-rw-rw-r--. 1 root root 3957 Oct 25 05:01 mime.types
-rw-rw-r--. 1 root root 6796 Oct 25 05:01 nginx.conf.example
-rw-rw-r--. 1 root root 1218 Oct 25 05:01 orange.conf.example
[root@localhost conf]#

两个配置文件nginx.conf 和 orange.conf ,官方提供了example,参照修改即可

[root@localhost conf]# pwd
/opt/orange/conf
[root@localhost conf]# ll
total 16
-rw-rw-r--. 1 root root 3957 Oct 25 05:01 mime.types
-rw-rw-r--. 1 root root 6796 Oct 25 05:01 nginx.conf.example
-rw-rw-r--. 1 root root 1218 Oct 25 05:01 orange.conf.example
[root@localhost conf]# vim orange.conf.example
[root@localhost conf]# vim nginx.conf.example
[root@localhost conf]# cp orange.conf.example orange.conf
[root@localhost conf]# cp nginx.conf.example nginx.conf
[root@localhost conf]# vim orange.conf
[root@localhost conf]#

修改 orange.conf 中的db配置

...
    "store": "mysql",
    "store_mysql": {
        "timeout": 5000,
        "connect_config": {
            "host": "127.0.0.1",
            "port": 3306,
            "database": "orange",
            "user": "root",
            "password": "123456",
            "charset": "utf8",
            "max_packet_size": 1048576
        },
        "pool_config": {
            "max_idle_timeout": 10000,
            "pool_size": 3
        },
        "desc": "mysql configuration"
...

dashboard前端的登录验证

...
    "dashboard": {
        "auth": true,       # true 表示dashboard需要登录
        "session_secret": "y0ji4pdj61aaf3f11c2e65cd2263d3e7e5",
        "whitelist": [
            "^/auth/login#34;,
            "^/error/#34;
        ]
    },
...

6.4 开发环境启动orange

注意: 当前路径为:orange,命令执行时需要按照当前所在路径查找配置文件,否则会报错,例如:

  • 错误:
[root@localhost bin]# pwd
/opt/orange/bin
[root@localhost bin]# ./orange start
ERROR: ./orange:38: module 'bin.main' not found:
	no field package.preload['bin.main']
	no file '/opt/orange/bin/deps/share/lua/5.1/orange/bin/main.lua'
	no file '/opt/orange/bin/deps/share/lua/5.1/bin/main.lua'
	no file '/usr/local/openresty/site/lualib/bin/main.ljbc'
	no file '/usr/local/openresty/site/lualib/bin/main/init.ljbc'
	no file '/usr/local/openresty/lualib/bin/main.ljbc'
	no file '/usr/local/openresty/lualib/bin/main/init.ljbc'
	no file '/usr/local/openresty/site/lualib/bin/main.lua'
	no file '/usr/local/openresty/site/lualib/bin/main/init.lua'
	no file '/usr/local/openresty/lualib/bin/main.lua'
	no file '/usr/local/openresty/lualib/bin/main/init.lua'
	no file './bin/main.lua'
	no file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/bin/main.lua'
	no file '/usr/local/share/lua/5.1/bin/main.lua'
	no file '/usr/local/share/lua/5.1/bin/main/init.lua'
	no file '/usr/local/openresty/luajit/share/lua/5.1/bin/main.lua'
	no file '/usr/local/openresty/luajit/share/lua/5.1/bin/main/init.lua'
	no file '/usr/local/openresty/site/lualib/bin/main.so'
	no file '/usr/local/openresty/lualib/bin/main.so'
	no file './bin/main.so'
	no file '/usr/local/lib/lua/5.1/bin/main.so'
	no file '/usr/local/openresty/luajit/lib/lua/5.1/bin/main.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
	no file '/usr/local/openresty/site/lualib/bin.so'
	no file '/usr/local/openresty/lualib/bin.so'
	no file './bin.so'
	no file '/usr/local/lib/lua/5.1/bin.so'
	no file '/usr/local/openresty/luajit/lib/lua/5.1/bin.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
	./orange:38: in function 'file_gen'
	init_worker_by_lua:46: in function <init_worker_by_lua:44>
	[C]: in function 'xpcall'
	init_worker_by_lua:53: in function <init_worker_by_lua:51>
[root@localhost bin]#
  • 正确:
[root@localhost orange]#
[root@localhost orange]# pwd
/opt/orange
[root@localhost orange]#
[root@localhost orange]# ./bin/orange start --orange_conf=/opt/orange/conf/orange.conf --prefix=/opt/orange --ngx_conf=/opt/orange/conf/nginx.conf
[INFO] Orange: 0.8.0
[INFO] ngx_lua: 10015
[INFO] nginx: 1015008
[INFO] Lua: LuaJIT 2.1.0-beta3
[INFO] args:
[INFO] 	ngx_conf:/opt/orange/conf/nginx.conf
[INFO] 	orange_conf:/opt/orange/conf/orange.conf
[INFO] 	prefix:/opt/orange
[INFO] args end.
[INFO] Start orange command execute.
[INFO] ORANGE_CONF=/opt/orange/conf/orange.conf openresty -p /opt/orange -c /opt/orange/conf/nginx.conf
[root@localhost orange]#
[root@localhost bin]#

至此,orange开发环境启动成功,可以开发自己的插件了。

7 生产环境安装orange

1. 启动orange

Orange放到/usr/local下, 可通过make install来安装。执行此命令:make install安装

[root@localhost local]# cd /opt/orange
[root@localhost orange]#
[root@localhost orange]# make install
/bin/sh: luarocks: command not found
install -d /usr/local/orange/logs
install -d /usr/local/orange/conf
install -d /usr/local/orange/dashboard/views
install -d /usr/local/orange/dashboard/static
install conf/nginx.conf.example /usr/local/orange/conf/nginx.conf
install conf/orange.conf.example /usr/local/orange/conf/orange.conf
install conf/mime.types /usr/local/orange/conf/mime.types
install install/orange-v0.8.0.sql /usr/local/orange/conf/orange-v0.8.0.sql
install -d /usr/share/lua/5.1/orange/dashboard
install -d /usr/share/lua/5.1/orange/orange
install -d /usr/share/lua/5.1/orange/bin
install -d /usr/share/lua/5.1/orange/api
cp -rf dashboard/* /usr/share/lua/5.1/orange/dashboard
cp -rf dashboard/views/* /usr/local/orange/dashboard/views
cp -rf dashboard/static/* /usr/local/orange/dashboard/static
cp -rf orange/* /usr/share/lua/5.1/orange/orange
cp -rf bin/* /usr/share/lua/5.1/orange/bin
cp -rf api/* /usr/share/lua/5.1/orange/api
install bin/orange /usr/bin/orange
rm -f /usr/local/bin/orange
ln -s /usr/bin/orange /usr/local/bin/orange

注意: 是原来没有安装luarocks包管理工具导致的提示没找到此命令,如果按照正常步骤就不会有此问题,相关包也会安装。

  • make install 执行结束之后,就可以启动 orange了。


欢迎 “关注” ,结合实际应用,持续更新orange网关系列。

最近发表
标签列表