# awdb-lua-nginx **Repository Path**: aiwen_home/awdb-lua-nginx ## Basic Information - **Project Name**: awdb-lua-nginx - **Description**: 使用lua语言解析awdb离线库 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-03-24 - **Last Updated**: 2024-12-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # awdb-lua-nginx www.ipplus360.com 官方支持的解析awdb格式的lua-nginx代码(Official support for parsing lua-nginx code in AWDB format) ## 服务使用和安装步骤如下: 1、lua 5.1.5安装(以下步骤需要使用root权限,已经安装的请忽略) (1) 安装依赖 ```shell sudo apt update sudo apt-get install -y libncurses5-dev build-essential libreadline6-dev ``` (2) 下载源码包并解压 ```shell sudo mkdir /opt/software wget https://www.lua.org/ftp/lua-5.1.5.tar.gz sudo tar -zxvf lua-5.1.5.tar.gz -C /opt/software ``` (3) 编译安装 ```shell cd /opt/software/lua-5.1.5 sudo make linux test sudo make install ``` 2、luarocks安装(以下步骤需要使用root权限,已经安装的请忽略) (1) 下载并解压 ```shell wget https://luarocks.github.io/luarocks/releases/luarocks-3.0.4.tar.gz sudo tar -zxvf luarocks-3.0.4.tar.gz -C /opt/software ``` (2) 编译安装 ```shell cd /opt/software/luarocks-3.0.4/ sudo ./configure --with-lua=/usr/local --with-lua-include=/usr/local/include sudo make sudo make install sudo make bootstrap ``` (3) 安装第三方库(需要在/opt/software/luarocks-3.0.4/进行安装) ```shell sudo luarocks install bitlib sudo luarocks install compat53 ``` (4) 将安装好的第三方库复制到`/usr/local/lib/lua/5.1/`目录下 ```shell sudo cp /opt/software/luarocks-3.0.4/lua_modules/lib/lua/5.1/bit.so /usr/local/lib/lua/5.1/bit.so sudo cp -r /opt/software/luarocks-3.0.4/lua_modules/lib/lua/5.1/compat53/ /usr/local/lib/lua/5.1/ ``` 3、openresty 安装 3.1 openresty 预编译包安装 ubuntu安装:http://openresty.org/cn/linux-packages.html#ubuntu 其它版本可参考openresty官网:http://openresty.org/cn/linux-packages.html 3.2 openresty 源码安装 (1) 下载并解压 ```shell wget https://openresty.org/download/openresty-1.21.4.1.tar.gz sudo tar -zxvf openresty-1.21.4.1.tar.gz -C /opt/software ``` (2) 安装依赖 ```shell sudo apt-get install -y libpcre3-dev libssl-dev perl make build-essential curl libpq-dev libpcre3 zlib1g-dev openssl ``` (3) 编译安装 ```shell cd /opt/software/openresty-1.21.4.1/ sudo ./configure sudo make sudo make install ``` 4、lua代码部署 (1) copy awdb目录到openresty的lualib目录 ```shell cp -R awdb /usr/local/openresty/lualib/ ``` 5、nginx项目配置 (1) 新建一个项目目录`awdb_test` ```shell mkdir -p /opt/awdb-lua/awdb_test cd /opt/awdb-lua/awdb_test ``` (2) 在项目目录`awdb_test`下创建配置文件目录conf和服务日志目录logs ```shell mkdir conf logs ``` (3) copy nginx配置文件`nginx.conf`到当前项目conf目录 ```shell cp nginx.conf conf/nginx.conf ``` (4) 修改`conf/nginx.conf` ```nginx configuration geodb1 = assert(awdb.read_awdb("test.awdb")) #服务端口修改(可以不改动, 默认8055) listen 8055; ``` 6、nginx服务启动 ```shell #在项目目录执行 sudo /usr/local/openresty/nginx/sbin/nginx -p `pwd`/ -c conf/nginx.conf ``` 7、简单使用样例 ```shell #linux curl命令 curl http://*.*.*.*:8055/czn?ip=1.0.15.255 ```