lua-cjson-plus

Configuring the binary installer repository

First, we need to configure the repository for the binary installer, as per the following command. (The CLIENT_TOKEN in the command needs to be replaced with a valid Token from the subscription email)

curl -o get-xray-priv-lib-repo.sh https://pkg2.openresty.com/scripts/get-xray-priv-lib-repo.sh

sudo bash get-xray-priv-lib-repo.sh -l openresty-lua-cjson -t CLIENT_TOKEN

Install the openresty-lua-cjson package

For CentOS/RockyLinux/Amazon Linux/Alibaba Cloud Linux/Tecent Linux operating systems using yum as the package manager, execute the following command to install the private libraries.

``bash sudo yum install –disablerepo="*" –enablerepo=openresty-lua-cjson -y openresty-lua-cjson


For operating systems such as `Fedora` that use `dnf` as package manager, execute the following command to install the private library.

```bash
sudo dnf install --disablerepo="*" --enablerepo=openresty-lua-cjson -y openresty-lua-cjson

For operating systems such as Ubuntu/Debian that use apt as the package manager, run the following command to install the private libraries.

sudo apt-get install -y openresty-lua-cjson

Using openresty-lua-cjson

  • Method 1: Specify lua_package_cpath`'' in the nginx.conf`’ configuration file

    http {
        lua_package_cpath '/usr/local/openresty/lua-cjson/lib/? .so;;'.
    }

    stream {
        lua_package_cpath '/usr/local/openresty/lua-cjson/lib/? .so;;'.
    }
  • Method 2: Softlink cjson.so to luajit’s default search directory

For example, the official so file provided by OpenResty is stored in the /usr/local/openresty/lualib/ directory. We can softlink cjson.so to that directory with the following command

ln -s /usr/local/openresty/lua-cjson/lib/cjson.so /usr/local/openresty/lualib