Skip to content

Building OpenResty

aborkar-ibm edited this page Oct 27, 2020 · 52 revisions

Building OpenResty

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

  • RHEL (7.6, 7.7, 7.8, 8.1, 8.2)
  • SLES (12 SP5, 15 SP1, 15 SP2)
  • Ubuntu (18.04, 20.04)

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.17.8.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.

Step 2: Install the dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.6, 7.7, 8.1, 8.2)

    sudo yum install -y curl tar wget make gcc gcc-c++ unix2dos cpan perl postgresql-devel patch pcre-devel readline-devel openssl openssl-devel glibc-common
  • RHEL (7.8)

    sudo yum downgrade -y glibc glibc-common
    sudo yum downgrade -y krb5-libs
    sudo yum downgrade -y libss e2fsprogs-libs e2fsprogs libcom_err
    sudo yum downgrade -y libselinux-utils libselinux-python libselinux
    sudo yum install -y curl tar wget make gcc gcc-c++ unix2dos cpan perl postgresql-devel patch pcre-devel readline-devel openssl openssl-devel
  • SLES 12 SP5

    sudo zypper install -y curl tar wget make gcc gcc-c++ dos2unix perl postgresql10-devel patch pcre-devel readline-devel openssl libopenssl-devel aaa_base
  • SLES (15 SP1, 15 SP2)

    sudo zypper install -y curl tar wget make gcc gcc-c++ dos2unix python3-lxml python3-curses perl postgresql10-devel patch pcre-devel readline-devel openssl openssl-devel aaa_base gzip glibc-i18ndata glibc-locale
    sudo localedef -i en_US -f UTF-8 en_US.UTF-8
  • Ubuntu (18.04, 20.04)

    sudo apt-get update
    sudo apt-get install -y curl tar wget make gcc dos2unix libreadline-dev patch libpcre3-dev libpcre3 libcurl4-openssl-dev libncursesada*-dev postgresql libpq-dev openssl libssl-dev perl zlib1g zlib1g-dev
    sudo ln -s make /usr/bin/gmake
  • Install Openssl ( Ubuntu 20.04 only )

    cd $SOURCE_ROOT
    wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1d.tar.gz
    tar xvf openssl-1.1.1d.tar.gz
    cd openssl-1.1.1d
    ./config --prefix=/usr/local --openssldir=/usr/local
    make
    sudo make install
    sudo ldconfig /usr/local/lib64
    echo ca-certificate=/etc/ssl/certs/ca-certificates.crt >> $HOME/.wgetrc
    export PATH=/usr/local/bin:$PATH
    

Note: Set /sbin to your PATH environment variable if not already set. Example: export PATH=$PATH:/sbin

Step 3: Download the source code

cd $SOURCE_ROOT
wget https://openresty.org/download/openresty-1.17.8.2.tar.gz
tar -xvf openresty-1.17.8.2.tar.gz

Step 4: Change the configure file for s390x

  • Change file $SOURCE_ROOT/openresty-1.17.8.2/configure by executing the following command:

    sed -i '742,785s/.*/#&/;717,726s/.*/#&/' $SOURCE_ROOT/openresty-1.17.8.2/configure

Note: -msse4.2 compilation option is not supported on s390x.

Step 5: Build and Install OpenResty

cd $SOURCE_ROOT/openresty-1.17.8.2
./configure --without-http_redis2_module --with-http_iconv_module --with-http_postgres_module
make -j2
sudo make install

Step 6: Testing (Optional)

6.1) Install cpan modules

sudo PERL_MM_USE_DEFAULT=1 cpan Cwd IO::Socket::SSL IPC::Run3 Test::Base Test::LongString

Note: For options prompted please select the default option.

6.2) Download files and modify to run sanity tests

mkdir $SOURCE_ROOT/openresty-1.17.8.2/t
cd $SOURCE_ROOT/openresty-1.17.8.2/t
wget https://raw.githubusercontent.com/openresty/openresty/v1.17.8.2/t/Config.pm
wget https://raw.githubusercontent.com/openresty/openresty/v1.17.8.2/t/000-sanity.t
  • Apply patch to file $SOURCE_ROOT/openresty-1.17.8.1/t/Config.pm

    PATCH_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/OpenResty/1.17.8.2/patch"
    curl -o "Config.pm.diff"  $PATCH_URL/Config.pm.diff
    patch -l $SOURCE_ROOT/openresty-1.17.8.2/t/Config.pm Config.pm.diff
  • Disable -msse4.2 option in file $SOURCE_ROOT/openresty-1.17.8.2/t/sanity.t for all distributions

    cd $SOURCE_ROOT/openresty-1.17.8.2/t
    sed -i "/configure line 719/d" 000-sanity.t
    sed -i "/configure line 764/d" 000-sanity.t
    sed -i "/INFO: found -msse4.2 in cc./d" 000-sanity.t
    sed -i "/WARNING: -msse4.2/d" 000-sanity.t
    sed -i "s/ XCFLAGS='-msse4.2'//g" 000-sanity.t
    sed -i "s/ -msse4.2//g" 000-sanity.t
    sed -i "s/-msse4.2 -DLUAJIT_ENABLE_LUA52COMPAT/-DLUAJIT_ENABLE_LUA52COMPAT/g" 000-sanity.t

6.3) Run test cases

export PERL5LIB=$SOURCE_ROOT/openresty-1.17.8.2   # For SLES 15.x,  RHEL 8.x and Ubuntu only
cd $SOURCE_ROOT/openresty-1.17.8.2
prove -r t

Step 7: Verify installed Openresty version

export PATH=/usr/local/openresty/bin:$PATH
resty -V

References

https://openresty.org/

Clone this wiki locally