Below is a simple way of installing RPMs needed to get PHP 7.0.13 & Nginx 1.11.8-1 running on an IBM i Power System.  By the end of it you’ll be able to send http requests to http://yoursite.com:61183/ that are answered by nginx and passed to php-fpm to process.

#get onto litmis
ssh usrcis42@spaces.litmis.com
#git ibmichroot project
git clone https://bitbucket.org/PHPDave/ibmichrootpulled1.22.2017 -c http.sslVerify=false
#switch to chroot project
cd ibmichrootpulled1.22.2017/pkg/
#Create PHP Pkg with content attached to this gist
joe pkg_perzl_php-7.0.13.lst
#Install PHP rpms from Perzl
./pkg_setup.sh pkg_perzl_php-7.0.13.lst
#Verify PHP-cli binary runs
/opt/freeware/bin/php -v
#Verify php-fpm can run on 127.0.0.1:9000 for Nginx to send requests to
/opt/freeware/sbin/php-fpm
joe /opt/freeware/etc/php-fpm.d/www.conf
#Download nginx and dependencies
./pkg_setup.sh pkg_perzl_nginx-1.11.8-1.lst
#Install Nginx – the pkg downloads it but this command has to run to install it
rpm –ignoreos –ignorearch –replacepkgs –nodeps -hUv –noscripts nginx-1.11.8-1.aix5.3.ppc.rpm
#configure Nginx to use php-fpm
joe /etc/nginx/nginx.conf
#setup nginx server – see file attached to gist – sets up the port and the connection to php-fpm
joe /etc/nginx/conf.d/virtual.conf
# we wont use the deafult config so we'll delete it
rm /etc/nginx/conf.d/default.conf
#start nginx
/etc/rc.d/init.d/nginx start
#create a test.php file to have nginx run and pass to PHP.
echo "<?php phpinfo(); ?>" >> /QOpenSys/opt/freeware/share/nginx/html/index.php
rm /QOpenSys/opt/freeware/share/nginx/html/index.html
#On browser go to http://spaces.litmis.com:61183/
#Some other documentation
#https://gist.github.com/phpdave/f8f56e5cb42c9f293c4ed02c7de8c30d
#Get IBM Db2
wget http://yips.idevcloud.com/wiki/uploads/XMLService/ibm_db2-1.9.9-zs5-php7.zip
#or compile from src http://yips.idevcloud.com/wiki/uploads/XMLService/ibm_db2-1.9.9-zs5-full-src.zip
wget http://www.oss4aix.org/download/RPMS/unzip/unzip-6.0-2.aix5.1.ppc.rpm
rpm –ignoreos –ignorearch –nodeps –replacepkgs -hUv unzip-6.0-2.aix5.1.ppc.rpm
unzip ibm_db2-1.9.9-zs5-php7.zip
#–add extension=ibm_db2.so
joe /opt/freeware/etc/php.ini
#–copy to extension dir
cp ibm_db2.so /opt/freeware/lib/php/modules/ibm_db2.so

# Command:
# > ./pkg_setup.sh pkg_perzl_php-7.0.13.lst
# Use:
# > export PATH=/opt/freeware/bin:$PATH
# > export LIBPATH=/opt/freeware/lib:$LIBPATH (if error, remove ':$LIBPATH')
# > any_util (below)
# Notes:
# requires pkg_perzl_gcc-4.8.3.lst
#
# rpm list
#
:rpm
# PHP
http://www.oss4aix.org/download/RPMS/php/mod_php_ap22-7.0.13-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/php/mod_php_ap24-7.0.13-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/php/php-cli-7.0.13-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/php/php-common-7.0.13-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/php/php-devel-7.0.13-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/php/php-fpm-7.0.13-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/php/php-opcache-7.0.13-1.aix5.1.ppc.rpm
#Dependencies
http://www.oss4aix.org/download/RPMS/bzip2/bzip2-1.0.2-4.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/curl/curl-7.51.0-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/freetype2/freetype2-2.7-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/libjpeg/libjpeg-9b-2.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/libpng/libpng-1.6.26-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/libmcrypt/libmcrypt-2.5.8-5.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/libssh2/libssh2-1.8.0-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/libtool/libtool-ltdl-2.4.6-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/libxml2/libxml2-2.9.4-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/libXpm/libXpm-3.5.11-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/openssl/openssl-1.0.2j-2.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/openldap/openldap-2.4.23-0.5.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/pcre/pcre-8.39-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/xz/xz-libs-5.2.2-1.aix5.1.ppc.rpm
http://www.oss4aix.org/download/RPMS/zlib/zlib-1.2.3-7.aix5.1.ppc.rpm
#http://www.oss4aix.org/download/RPMS/libiconv/libiconv-1.14-3.aix5.1.ppc.rpm
#Apache
#http://www.oss4aix.org/download/RPMS/apache/httpd-2.2.31-1.aix5.1.ppc.rpm

#
# A virtual host using mix of IP-, name-, and port-based configuration
#
server {
listen 61183;
# listen somename:8080;
# server_name somename alias another.alias;
location / {
root html;
index index.php index.html index.htm;
}
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9001;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}

view raw
virtual.conf
hosted with ❤ by GitHub

<?php
//phpinfo();
$database = '*LOCAL';
$username = 'USRYB87R';
$password = '';
$db2Connection = db2_connect($database , $username , $password );
echo 'Connection Result for '.$database.':';
var_dump($db2Connection);
echo '<br>';
if(!$db2Connection)
{
echo 'db2_conn_error():'.db2_conn_error()."<br>";
echo 'db2_conn_errormsg():'.db2_conn_errormsg()."<br>";
}
$sql_query = "select current date from sysibm.sysdummy1";
$sql_statement = db2_prepare($db2Connection, $sql_query);
if($sql_statement ===false) {echo 'Prepare Failed – Error: ' . db2_stmt_error() . "|".db2_stmt_errormsg() ;}
$ID=1;
db2_bind_param($sql_statement, 1, "ID", DB2_PARAM_IN);
db2_execute($sql_statement);
$row = db2_fetch_assoc($sql_statement);
var_dump($row);
//Output:
//Connection Result for *LOCAL:resource(2) of type (DB2 Connection)
//array(1) { ["00001"]=> string(10) "2017-01-23" }

view raw
zindex.php
hosted with ❤ by GitHub