Skip to content

Building OpenResty

aborkar-ibm edited this page Aug 7, 2019 · 52 revisions

Building OpenResty

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

  • RHEL (6.10, 7.5, 7.6, 8.0)
  • SLES (12 SP4, 15)
  • Ubuntu (16.04, 18.04, 19.04)

Prerequisites:

  • LuaJIT -- Instructions for building LuaJIT can be found here

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.

Step 1: Install the dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (6.10, 7.5, 7.6, 8.0)

    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
    
  • SLES 12 SP4

    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

    sudo zypper install -y git tar wget make gcc gcc-c++ unix2dos hg perl postgresql10-devel patch pcre-devel readline-devel openssl openssl-devel aaa_base gzip
    
  • Ubuntu (16.04, 18.04, 19.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
    

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

Step 2: Download the source code

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

Step 3: Change the configure file for s390x: /<source_root>/openresty-1.15.8.1/configure:

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

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

Step 4: Build and install OpenResty

cd $SOURCE_ROOT/openresty-1.15.8.1    
rm -rf $SOURCE_ROOT/openresty-1.15.8.1/bundle/LuaJIT-2.1-20190507/*
cp -r $SOURCE_ROOT/LuaJIT/* $SOURCE_ROOT/openresty-1.15.8.1/bundle/LuaJIT-2.1-20190507/
cd $SOURCE_ROOT/openresty-1.15.8.1
./configure --without-http_redis2_module --with-http_iconv_module --with-http_postgres_module  -j2 
make -j2 
sudo make install

Step 5: Configure Nginx module

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

Step 6: Verify installed Openresty version

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

Notes: Openresty installation is completed. Please follow the below optional steps to run sanity tests on Openresty.

Step 7: Install cpan modules

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

Notes:

1. For options prompted please select the default option.

2. In RHEL 6.10 , if you get the error sudo: cpan: command not found , use the absolute path for cpan.

3. If you get the warning perl: warning: Setting locale failed.on SLES 15, run below commands.

sudo zypper install -y glibc-i18ndata glibc-locale
sudo localedef -i en_US -f UTF-8 en_US.UTF-8

Step 8: Download files and modify to run sanity tests

mkdir $SOURCE_ROOT/openresty-1.15.8.1/t
cd $SOURCE_ROOT/openresty-1.15.8.1/t
wget https://raw.githubusercontent.com/openresty/openresty/v1.15.8.1/t/Config.pm
wget https://raw.githubusercontent.com/openresty/openresty/v1.15.8.1/t/sanity.t
  • Edit file /<source_root>/openresty-1.15.8.1/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.1/t/sanity.t

    • SLES (12 SP4, 15) and Ubuntu (16.04, 18.04, 19.04)

      @@ -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.1/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

Step 9: Run test cases

export PERL5LIB=$SOURCE_ROOT/openresty-1.15.8.1 # For SLES 15, RHEL 8.0 and Ubuntu 18.04, 19.04 only
cd $SOURCE_ROOT/openresty-1.15.8.1
prove -r t

References

https://openresty.org/

Clone this wiki locally