Skip to content

Building OpenResty

aborkar-ibm edited this page Apr 14, 2020 · 52 revisions

Building OpenResty

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

  • RHEL (7.6, 7.7, 7.8, 8.0, 8.1)
  • SLES (12 SP4, 12 SP5, 15 SP1)
  • Ubuntu (16.04, 18.04, 19.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.

Building and Installing 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.15.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, 7.8, 8.0, 8.1)

    sudo yum install -y git tar wget make gcc gcc-c++ unix2dos hg cpan perl postgresql-devel patch pcre-devel readline-devel openssl openssl-devel glibc-common
  • SLES (12 SP4, 12 SP5)

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

    sudo zypper install -y git tar wget make gcc gcc-c++ unix2dos mercurial python-xml python-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 (16.04, 18.04)

    sudo apt-get update
    sudo apt-get install -y git tar wget make gcc dos2unix hgview 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
  • Ubuntu 19.10

    sudo apt-get update
    sudo apt-get install -y git 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

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.15.8.2.tar.gz
tar -xvf openresty-1.15.8.2.tar.gz

Step 4: Change the configure file for s390x

  • Change file /<source_root>/openresty-1.15.8.2/configure by executing the following commands:

    sed -i '730,773s/.*/#&/' $SOURCE_ROOT/openresty-1.15.8.2/configure
    sed -i '723s/.*/#&/' $SOURCE_ROOT/openresty-1.15.8.2/configure
    sed -i '704,713s/.*/#&/' $SOURCE_ROOT/openresty-1.15.8.2/configure

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

Step 5: Build and install OpenResty

cd $SOURCE_ROOT
rm -rf $SOURCE_ROOT/openresty-1.15.8.2/bundle/LuaJIT-2.1-20190507/*
wget https://github.com/openresty/luajit2/archive/v2.1-20190912.tar.gz
tar -zxvf v2.1-20190912.tar.gz
cp -r $SOURCE_ROOT/luajit2-2.1-20190912/* $SOURCE_ROOT/openresty-1.15.8.2/bundle/LuaJIT-2.1-20190507/
cd $SOURCE_ROOT/openresty-1.15.8.2
./configure --without-http_redis2_module --with-http_iconv_module --with-http_postgres_module
make -j2
sudo make install

Step 6: Configure Nginx module

cd $SOURCE_ROOT/openresty-1.15.8.2/build/nginx-1.15.8
./configure && make && sudo make install

Step 7: Testing (Optional)

7.1) Install cpan modules

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

Note: For options prompted please select the default option.

7.2) Download files and modify to run sanity tests

mkdir $SOURCE_ROOT/openresty-1.15.8.2/t
cd $SOURCE_ROOT/openresty-1.15.8.2/t
wget https://raw.githubusercontent.com/openresty/openresty/v1.15.8.2/t/Config.pm
wget https://raw.githubusercontent.com/openresty/openresty/v1.15.8.2/t/sanity.t
  • Edit file $SOURCE_ROOT/openresty-1.15.8.2/t/Config.pm

    @@ -20,10 +20,6 @@
    chomp $RootDir;
    
    sub run_tests {
    -    my $ver = `bash util/ver`;
    -    chomp $ver;
    -
    -    cd "openresty-$ver";
    
        $DistRoot = cwd();
        $BuildRoot = File::Spec->rel2abs("./build");
  • Edit file $SOURCE_ROOT/openresty-1.15.8.2/t/sanity.t

    • SLES (12 SP4, 12 SP5, 15 SP1) and Ubuntu (16.04, 18.04, 19.10)

      @@ -1814,8 +1814,8 @@ clean:
      platform: linux \(linux\)
      cp -rp bundle/ build
      cd build
      -export LIBPQ_LIB='(/usr/lib64|/usr/lib/x86_64-linux-gnu)'
      -export LIBPQ_INC='(?:/usr/include|/usr/include/postgresql)'
      +export LIBPQ_LIB='(/usr/lib64|/usr/lib/s390x-linux-gnu|/usr/lib/postgresql10/lib64)'
      +export LIBPQ_INC='(?:/usr/include|/usr/include/postgresql|/usr/include/pgsql)'
      cd LuaJIT-2.1-20190507
      INFO: found -msse4.2 in cc.
      gmake TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT -DLUAJIT_ENABLE_GC64 -msse4.2' CC=cc PREFIX=/usr/local/openresty/luajit
    • All Distributions

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

7.3) Run test cases

export PERL5LIB=$SOURCE_ROOT/openresty-1.15.8.2 # For SLES 15 SP1,  RHEL (8.0, 8.1) and Ubuntu (18.04, 19.10)
cd $SOURCE_ROOT/openresty-1.15.8.2
prove -r t

Step 8: Verify installed Openresty version

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

References

https://openresty.org/

Clone this wiki locally