Building OpenResty - linux-on-ibm-z/docs GitHub Wiki
Building OpenResty
The instructions provided below specify the steps to build OpenResty 1.25.3.1 on Linux on IBM Z for the following distributions:
- RHEL (7.8, 7.9, 8.6, 8.8, 8.9, 9.0, 9.2, 9.3)
- SLES (12 SP5, 15 SP5)
- Ubuntu (20.04, 22.04, 23.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
Step 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.25.3.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.
Step 2: Install the dependencies
export SOURCE_ROOT=/<source_root>/
-
RHEL (7.8, 7.9)
sudo yum install -y curl tar wget make devtoolset-7 rh-git227-git.s390x dos2unix perl patch pcre-devel zlib-devel perl-App-cpanminus #switch to GCC 7 source /opt/rh/devtoolset-7/enable #Enable git 2.27 source /opt/rh/rh-git227/enable
-
RHEL (8.6, 8.8, 8.9, 9.0, 9.2, 9.3)
sudo yum install -y openssl-devel curl tar wget make gcc dos2unix perl patch pcre-devel zlib-devel perl-App-cpanminus git
-
SLES 12 SP5
sudo zypper install -y openssl-devel git curl tar wget make gcc7 dos2unix perl patch libpcre1 pcre-devel gzip zlib-devel libnghttp2-devel which sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-7 40 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 40 curl -L https://cpanmin.us | perl - --sudo App::cpanminus
-
SLES 15 SP5
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, 23.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
Step 3: Clone OpenResty repository
cd $SOURCE_ROOT
git clone -b v1.25.3.1 https://github.com/openresty/openresty.git
Step 4: Patch and Install openssl from source (Only for RHEL 7.x)
cd $SOURCE_ROOT
wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1l.tar.gz
tar xvf openssl-1.1.1l.tar.gz
cd openssl-1.1.1l
patch -p1 < ../openresty/patches/openssl-1.1.1f-sess_set_get_cb_yield.patch
./config no-threads shared enable-ssl3 enable-ssl3-method -g --prefix=/usr/local -DPURIFY
make -j$(nproc)
sudo make PATH=$PATH install_sw
sudo ln -sf /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
sudo ln -sf /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
Step 5: Download the source code
cd $SOURCE_ROOT/openresty
wget --no-check-certificate https://openresty.org/download/openresty-1.25.3.1.tar.gz
tar xvf openresty-1.25.3.1.tar.gz
Step 6: Build and Install OpenResty
cd $SOURCE_ROOT/openresty/openresty-1.25.3.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.
Step 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.
Step 8: Verify installed OpenResty version
resty -V
resty -e 'print("hello, world")'