Building OpenResty - linux-on-ibm-z/docs GitHub Wiki
Building OpenResty
The instructions provided below specify the steps to build OpenResty 1.27.1.2 on Linux on IBM Z for the following distributions:
- RHEL (8.8, 8.10, 9.2, 9.4, 9.5)
- SLES (15 SP6)
- Ubuntu (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.2/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, 9.5)
sudo yum install -y openssl-devel curl tar wget make gcc dos2unix perl patch pcre-devel zlib-devel perl-App-cpanminus git
-
SLES (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 (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.2 https://github.com/openresty/openresty.git
4. Install PCRE2-JIT
cd $SOURCE_ROOT/openresty
export PCRE_VER=10.44
export PCRE_PREFIX=/opt/pcre2
export PCRE_LIB=$PCRE_PREFIX/lib
export PCRE_INC=$PCRE_PREFIX/include
wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${PCRE_VER}/pcre2-${PCRE_VER}.tar.gz
tar -xzf pcre2-$PCRE_VER.tar.gz
cd pcre2-$PCRE_VER/
./configure --prefix=$PCRE_PREFIX --enable-jit --enable-utf --enable-unicode-properties
make -j$JOBS
sudo PATH=$PATH make install
5. Download the source code
cd $SOURCE_ROOT/openresty
wget --no-check-certificate https://openresty.org/download/openresty-1.27.1.2.tar.gz
tar xvf openresty-1.27.1.2.tar.gz
6. Build and Install OpenResty
cd $SOURCE_ROOT/openresty/openresty-1.27.1.2
export PATH=$PATH:/sbin # Only on SLES
./configure --prefix=/usr/local/openresty \
--with-pcre-jit \
--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
7. Testing (Optional)
7.1. Install cpan modules
sudo cpanm --notest Test::Nginx IPC::Run3
7.2. Run test cases
cd $SOURCE_ROOT/openresty
prove -I. -r t/
All the test cases should pass.
8. Verify installed OpenResty version
resty -V
resty -e 'print("hello, world")'