Skip to content

Building OpenResty

linuxonz edited this page Nov 7, 2024 · 49 revisions

Building OpenResty

The instructions provided below specify the steps to build OpenResty 1.27.1.1 on Linux on IBM Z for the following distributions:

  • RHEL (8.8, 8.10, 9.2, 9.4)
  • SLES (15 SP5, 15 SP6)
  • Ubuntu (20.04, 22.04, 24.04, 24.10)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.

  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Build and Install OpenResty

1. Build using script

If you want to build OpenResty using manual steps, go to Step 2.

Use the following commands to build OpenResty using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/OpenResty/1.27.1.1/build_openresty.sh
# Build OpenResty
bash build_openresty.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 8. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

2. Install the dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (8.8, 8.10, 9.2, 9.4)

    sudo yum install -y openssl-devel curl tar wget make gcc dos2unix perl patch pcre-devel zlib-devel perl-App-cpanminus git
  • SLES (15 SP5, 15 SP6)

    sudo zypper install -y openssl-devel git curl tar wget make gcc dos2unix perl patch pcre-devel gzip zlib-devel perl-App-cpanminus
  • Ubuntu (20.04, 22.04, 24.04, 24.10)

    sudo apt-get update
    sudo apt-get install -y openssl libssl-dev git curl tar wget make gcc build-essential dos2unix patch libpcre3-dev libpq-dev perl cpanminus zlib1g-dev
    sudo ln -s /usr/bin/make /usr/bin/gmake  # Only if /usr/bin/gmake doesn't exist

3. Clone OpenResty repository

cd $SOURCE_ROOT
git clone -b v1.27.1.1 https://github.com/openresty/openresty.git

4. Download the source code

cd $SOURCE_ROOT/openresty
wget --no-check-certificate https://openresty.org/download/openresty-1.27.1.1.tar.gz
tar xvf openresty-1.27.1.1.tar.gz

5. Build and Install OpenResty

cd $SOURCE_ROOT/openresty/openresty-1.27.1.1
export PATH=$PATH:/sbin  # Only on SLES
./configure --prefix=/usr/local/openresty \
            --with-cc-opt="-I/usr/local/include" \
            --with-ld-opt="-L/usr/local/lib -Wl,-rpath,/usr/local/lib" \
            --with-http_ssl_module \
            --with-http_iconv_module \
            --with-debug \
            -j$(nproc)
make -j$(nproc)
sudo make install
export PATH=/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin:$PATH

Note: --with-pcre-jit is not included in options for ./configure command, since JIT in PCRE is not supported on s390x yet.

6. Testing (Optional)

6.1. Install cpan modules

sudo cpanm --notest Test::Nginx IPC::Run3

6.2. Run test cases

# The test expects different module versions than those being installed by the Makefile.
cd $SOURCE_ROOT/openresty/t/; sed -i 's/lua-resty-lrucache-0.14/lua-resty-lrucache-0.15/g' 000-sanity.t
cd $SOURCE_ROOT/openresty/t/; sed -i 's/lua-resty-core-0.1.29/lua-resty-core-0.1.30/g' 000-sanity.t

cd $SOURCE_ROOT/openresty
prove -I. -r t/

All the test cases should pass.

7. Verify installed OpenResty version

resty -V
resty -e 'print("hello, world")'

References

Clone this wiki locally