linux系統離線安裝orange實戰
一、openssl
A.簡介
- 一個強大的,商業級的,功能齊全的工具包,用於通用加密和安全通信。
- 官網
B.安裝
二、openresty
A.簡介
- OpenResty® 是一個成熟的網絡平臺,它集成了我們的 Nginx核心的增強版,我們的LuaJIT增強版,許多精心編寫的Lua 庫,許多高質量的第三方Nginx模塊,以及 他們的大多數外部依賴關係。它旨在幫助開發人員輕鬆 構建可擴展的 Web 應用程序、Web 服務和動態 Web 網關。
- 官網
B.安裝
C.配置
- 指定openssl庫:
./configure --prefix=/home/was/install/openresty-1.21.4.1 --with-http_stub_status_module --with-openssl=/usr/lib64/openssl
- 執行:
gmake && gmake install
- 環境變量:
export PATH=/home/was/install/openresty-1.21.4.1/nginx/sbin:$PATH
export LPATH=$LPATH:/home/was/install/openresty-1.21.4.1/luajit/lib:/usr/lib64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/was/install/openresty-1.21.4.1/luajit/lib:/usr/lib64
D.驗證
resty -v
三、lor
A.簡介
- Lor是一個運行在OpenResty上的使用Lua編寫的Web框架。 它兼顧開發效率和運行時性能, 可用於快速開發API Server和傳統Web頁面應用。
- 官網
B.安裝
- 請先確保已安裝OpenResty和luajit
- 官網安裝
C.配置
- 修改openresty中makefile文件中目錄爲需要安裝的目錄:
LOR_HOME ?= /home/was/install/lor-0.3.4
LORD_BIN ?= /home/was/install/lor-0.3.4/bin
- 執行:
make install (或 gmake install)
- 環境變量:
export PATH=/home/was/install/lor-0.3.4/bin:$PATH
export PATH=$PATH:/home/was/install/lor-0.3.4/bin
D.驗證
lord -v
四、orange
A.簡介
- Orange是一個基於OpenResty的API網關。除Nginx的基本功能外,它還可用於API監控、訪問控制(鑑權、WAF)、流量篩選、訪問限速、AB測試、動態分流等。
- 官網
B.安裝
C.配置
- 修改配置文件: nginx.conf orange.conf
- 環境變量:
export PATH=/home/was/install/orange/bin:$PATH
五、mysql
A.安裝
B.配置
- 新建mysql組和用戶
groupadd mysql //新建組
useradd -d /home/mysql -g mysql mysql //新建用戶
- 修改文件/etc/my.conf
- 配置環境變量:
export PATH=$PATH:/usr/local/mysql/bin
- 初始化mysql數據庫
./mysqlld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --explicit_defaults_for_timestamp
- 將mysql啓動命令拷貝到/etc/init.d中
cp mysql/support-files/mysql.server /etc/init.d/mysql
- 啓動mysql服務
service mysql start
service mysql restart
- 新建用戶及授權
create user 'xxx'@'%' identified by 'xxxxx';
grant all on *.* to 'xxx'@'%' identified by 'xxxxx';
- 執行初始化腳本
use mysql;
source /usr/local/mysql/tmp_sql_files/mysql_tables.sql
六、安裝luarocks到openresty中
A.簡介
- LuaRocks是Lua模塊的包管理器。
- 官網
B.安裝
- 官網下載
- 解壓後進行如下配置
./configure --prefix=/usr/local/openresty/luajit --with-lua=/usr/local/openresty/luajit/ --lua-suffix=jit --with-lua-include=/usr/local/openresty/luajit/include/luagit-2.1
make && make install
- 參考文件 將luarocks整合到openresty中
C.說明
- --prefix 設置 Luarocks 安裝路徑,--with-lua 指定 Luarocks 依賴的 Lua 安裝路徑。設置 prefix 會自動將 Luarocks 以及往後使用 Luarocks 安裝的 Lua 包,LuaC 包都安裝到 Luarocks 安裝路徑下的相應位置,否則相關的包文件散落在文件系統中,顯得雜亂不便於管理,如果所安裝的 Lua 模板包含 bin 文件,則會自動安裝到此目錄下的 bin 路徑,與 Luarocks 可執行文件同一路徑,更便於管理、使用。
- make install會將編譯好的luarocks安裝到/usr/local/openresty相關目錄:/usr/local/openresty/luajit/share/lua/5.1/luarocks
七、安裝lua模塊(示例:aes_everywhere)
A.安裝
1、外網 ./luarocks install aes_everywhere
B.實際修改位置
- /usr/local/openresty/luajit/lib/luarocks文件夾
- /usr/local/openresty/luajit/share/lua/5.1/下除luarocks外文件及文件夾
C.orange目錄修改(加解密orange提交記錄)
- orange.conf中plugins添加'encrypt'模塊,orange.conf中添加encryptpwd常量
- /dashboard/routes/dashboard.lua 中添加請求
dashboard_router:get("/encrypt", function(req, res, next)
res:render("encrypt")
end)
- /dashboard/views/common/condition-add.html 增加條件
<option value="Method">Method</option>
- /dashboard/views/common/left_nav.html 增加顯示
<li id="nav-encrypt">
<a href="/encrypt">
<i class="fa fa-arrows"></i>
<span class="nav-label">傳輸加密</span>
</a>
</li>
- 新增加密解密包
commit 44e6566ca02c960bed58e450fb99d8f87c868a28 (readme)
commit 02c59166fe165798130aaa633a3f65ac4fd1747d (add axios example, add encryptpwd config)
commit 0f9f320f51dd1fa31cc10d52409c056d775e3b1d (add encrypt plugin)
八、注意事項
A.提前下載好需要安裝的包文件
B.環境變量需要配置在文件中才能永久生效
- root用戶: /etc/profile
- 普通用戶: /home/用戶名/.bashrc (一般設置這裏就可以)
- 使文件生效: source .bashrc