Skip to content

Building OpenResty

aborkar-ibm edited this page Apr 6, 2017 · 52 revisions

Building OpenResty

The instructions provided below specify the steps to build OpenResty 1.11.2.2 on IBM z Systems for following distibutions:

  • RHEL (6.8, 7.1, 7.2, 7.3)
  • SLES (11 SP4, 12, 12 SP1, 12 SP2)
  • Ubuntu (16.04, 16.10)

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

  • RHEL 6.8

    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
    
    • Build GCC 4.8.2:

       cd /<source_root>/
       sudo yum install -y flex binutils-devel bzip2
       wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2
       tar xvf gcc-4.8.2.tar.bz2
       cd gcc-4.8.2
       ./contrib/download_prerequisites
       mkdir /<source_root>/gccbuild
       cd /<source_root>/gccbuild
       ../gcc-4.8.2/configure  --prefix="/opt/gcc"  --enable-shared --with-system-zlib --enable-threads=posix  --enable-__cxa_atexit --enable-checking --enable-gnu-indirect-function  --enable-languages="c,c++" --disable-bootstrap --disable-multilib
       make all
       sudo make install
       export PATH=/opt/gcc/bin:$PATH
       export LD_LIBRARY_PATH='/opt/gcc/$LIB'
       sudo mv /usr/bin/gcc /usr/bin/gcc.bkup
       sudo ln -s /opt/gcc/bin/gcc /usr/bin/gcc
  • RHEL (7.1, 7.2, 7.3)

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 11 SP4

    sudo zypper install -y git tar wget make gcc gcc-c++ mercurial patch pcre-devel readline-devel openssl libopenssl-devel aaa_base awk flex bison
    
    • Install unix2dos 4.1

       cd /<source_root>
       wget https://waterlan.home.xs4all.nl/unix2dos/unix2dos-4.1.tar.gz
       tar xvf unix2dos-4.1.tar.gz
       cd unix2dos-4.1
       make
       sudo make install
    • Install Perl 5.10.1

       cd /<source_root>
       wget http://www.cpan.org/src/5.0/perl-5.10.1.tar.gz
       tar xvf perl-5.10.1.tar.gz
       cd perl-5.10.1
       ./Configure -des -Dprefix=/usr/local/perl
       make
       sudo make install
       export PATH=/usr/local/perl/bin/:$PATH
       perl -v
    • Install PostgreSQL 9.6.2

       cd /<source_root>
       git clone https://github.com/postgres/postgres.git
       cd postgres
       git checkout REL9_6_2
       ./configure
       make && sudo make install
       export PATH=$PATH:/usr/local/pgsql/bin
       export LD_LIBRARY_PATH=/usr/local/pgsql/lib
  • SLES (12, 12 SP1, 12 SP2)

sudo zypper install -y git tar wget make gcc gcc-c++ unix2dos hg perl postgresql-devel patch pcre-devel readline-devel openssl openssl-devel aaa_base
  • Ubuntu (16.04, 16.10)
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
sudo ln -s make /usr/bin/gmake

Note: Set /sbin to your PATH environment variable if not already set.

Step 2: Download the source code

cd /<source_root>
git clone https://github.com/openresty/openresty.git
cd openresty
git checkout v1.11.2.2

Step 3: Build and install OpenResty

cd /<source_root>/openresty    
make	
rm -rf /<source_root>/openresty/openresty-1.11.2.2/bundle/LuaJIT-2.1-20161104/
cp -r /<source_root>/LuaJIT /<source_root>/openresty/openresty-1.11.2.2/bundle/LuaJIT-2.1-20161104/
cd /<source_root>/openresty/openresty-1.11.2.2
./configure --without-http_redis2_module --with-http_iconv_module --with-http_postgres_module  -j2 
make -j2 
sudo make install

Step 4: Configure Nginx module

cd /<source_root>/openresty/openresty-1.11.2.2/build/nginx-1.11.2
./configure && make && sudo make install

Step 5: Install cpan modules

sudo cpan Cwd IPC::Run3 Test::Base Test::LongString

Notes:

1. For options prompted please select the default option.

2. If you get the warning perl: warning: Setting locale failed. , set LANG environtment variable.

  export LANG=C

Step 6: Edit file /<source_root>/openresty/t/sanity.t

  • Ubuntu (16.04, 16.10)
@@ -1936,8 +1936,8 @@
platform: linux (linux)
cp -rp bundle/ build
cd build
-export LIBPQ_LIB='/usr/lib64'
-export LIBPQ_INC='/usr/include'
+export LIBPQ_LIB='/usr/lib/s390x-linux-gnu'
+export LIBPQ_INC='/usr/include/postgresql'
cd lua-5.1.5
gmake linux
gmake install INSTALL_TOP=$OPENRESTY_BUILD_DIR/lua-root//usr/local/openresty/lua/
@@ -1965,7 +1965,7 @@
 --add-module=../redis-nginx-module-0.3.7 \
 --add-module=../rds-json-nginx-module-0.14 \
 --add-module=../rds-csv-nginx-module-0.07 \
-  --with-ld-opt='-Wl,-rpath,/usr/lib64' \
+  --with-ld-opt='-Wl,-rpath,/usr/lib/s390x-linux-gnu' \
 --with-http_ssl_module
cd ../..
Type the following commands to build and install:
  • SLES 11 SP4
@@ -1916,7 +1918,7 @@

 --- err
 --with-pg_config is not allowed when --with-libpq is already specified.
-  --- exit: 255
+  --- exit: 9



@@ -1936,8 +1938,8 @@
platform: linux (linux)
cp -rp bundle/ build
cd build
-export LIBPQ_LIB='/usr/lib64'
-export LIBPQ_INC='/usr/include'
+export LIBPQ_LIB='/usr/local/pgsql/lib'
+export LIBPQ_INC='/usr/local/pgsql/include'
cd lua-5.1.5
gmake linux
gmake install INSTALL_TOP=$OPENRESTY_BUILD_DIR/lua-root//usr/local/openresty/lua/
@@ -1965,7 +1967,7 @@
 --add-module=../redis-nginx-module-0.3.7 \
 --add-module=../rds-json-nginx-module-0.14 \
 --add-module=../rds-csv-nginx-module-0.07 \
-  --with-ld-opt='-Wl,-rpath,/usr/lib64' \
+  --with-ld-opt='-Wl,-rpath,/usr/local/pgsql/lib' \
 --with-http_ssl_module
cd ../..
Type the following commands to build and install:
  • SLES 12
@@ -1936,8 +1936,8 @@
platform: linux (linux)
cp -rp bundle/ build
cd build
-export LIBPQ_LIB='/usr/lib64'
-export LIBPQ_INC='/usr/include'
+export LIBPQ_LIB='/usr/lib/postgresql93/lib64'
+export LIBPQ_INC='/usr/include/pgsql'
cd lua-5.1.5
gmake linux
gmake install INSTALL_TOP=$OPENRESTY_BUILD_DIR/lua-root//usr/local/openresty/lua/
@@ -1965,7 +1965,7 @@
 --add-module=../redis-nginx-module-0.3.7 \
 --add-module=../rds-json-nginx-module-0.14 \
 --add-module=../rds-csv-nginx-module-0.07 \
-  --with-ld-opt='-Wl,-rpath,/usr/lib64' \
+  --with-ld-opt='-Wl,-rpath,/usr/lib/postgresql93/lib64' \
 --with-http_ssl_module
cd ../..
Type the following commands to build and install:
  • SLES (12 SP1, 12 SP2)
@@ -1936,8 +1936,8 @@
platform: linux (linux)
cp -rp bundle/ build
cd build
-export LIBPQ_LIB='/usr/lib64'
-export LIBPQ_INC='/usr/include'
+export LIBPQ_LIB='/usr/lib/postgresql94/lib64'
+export LIBPQ_INC='/usr/include/pgsql'
cd lua-5.1.5
gmake linux
gmake install INSTALL_TOP=$OPENRESTY_BUILD_DIR/lua-root//usr/local/openresty/lua/
@@ -1965,7 +1965,7 @@
 --add-module=../redis-nginx-module-0.3.7 \
 --add-module=../rds-json-nginx-module-0.14 \
 --add-module=../rds-csv-nginx-module-0.07 \
-  --with-ld-opt='-Wl,-rpath,/usr/lib64' \
+  --with-ld-opt='-Wl,-rpath,/usr/lib/postgresql94/lib64' \
 --with-http_ssl_module
cd ../..
Type the following commands to build and install:

Step 7: Run test cases (Optional)

cd /<source_root>/openresty
make test

References

https://openresty.org/

Clone this wiki locally