How to Install PHP 7.0.13 and Nginx 1.11.8 from Perzl on IBM i using PHP-FPM

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 that are answered by nginx and passed to php-fpm to process.


Setting the Zend DB DB2 connection’s library list to the user’s library list

Recently a friend ran into this issue. One way to correct this issue is to set the i5_libl option on the db2 connection options ( Another way to do this is by changing the job description associated with the IBM i user profile by using the command CHGJOBD in a 5250 session. You would set the INLLIBL to LIBL (library list) you want to use. Then assign the jobd
(job description) to user profile your connecting with DB2_connect or Zend_DB and the ibmdb2 adapter.

For example:


Then associate this jobd with the user profile

To Debug the issue there are a few DB2 for i services you can call from PHP via SQL and they are:

Clean phone number field with IBM DB2 for i SQL REGEXP_REPLACE

Say you have a phone number in various formats but you just want the numeric characters and all the non-numeric characters removed. Well use the SQL function REGEXP_REPLACE and look for characters with the regular expression [^\d] and replace it with empty character ”. [^\d] is a negated set which means match any characters not in between [^ and ]. \d is a short hand way of saying all digit characters 0-9.



IBM documentation on REGEXP_REPLACE

Online regex tester tool

A few tips on Locking down WordPress

Add the following code to your .htaccess file or into your apache vhost config so that some things will be blocked

#block wp-config.php

order allow,deny
deny from all

#block wp-login.php

order deny,allow
deny from all
#optionally add ips that you want to allow from
#Allow from 10.

#block xmlrpc.php another way to login

order deny,allow
deny from all
#optionally add ips that you want to allow from
#Allow from 10.

#block author lookup (used by hackers to get your username)
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (author=\d+) [NC]
RewriteRule .* /index.php?error=403 [L]

#block includes

RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ – [F,L]
RewriteRule !^wp-includes/ – [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ – [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php – [F,L]
RewriteRule ^wp-includes/theme-compat/ – [F,L]

Simple shell command to show 404 pages by occurrence from Apache logs

With the command below you can see all the 404 errors in your apache access logs. You’ll have to change /var/log/httpd/ to the path of your log file and change 20/Oct/2016:15 to the date and hour you want to look at

grep 20/Oct/2016:15 /var/log/httpd/ | grep 404 | cut -d'"' -f2,3 | awk '$4=404{print 404" "$2" "$4}' | sort | uniq -c | sort -rg


Setting up Vagrant

You’ll need Virtual box so download and install that

Then you’ll need vagrant

You can check out the getting started guide here:

Simple example:

Open a terminal session (iTerm2 on mac or cmder windows) and run:

vagrant init hashicorp/precise64
vagrant up
vagrant ssh
vagrant destroy

Lets make our own

mkdir MyFirstVagrant
cd MyFirstVagrant/
vagrant init

Lets commit it to a github repo so we have source control on it.  Go to and create a repo.  Replace the url below with your .git file.

echo "# Vagrants" >>
git init
git add
git commit -m "first commit"
git remote add origin
git push -u origin master

Lets find a box we want to add to our vagrantfile

I chose the most popular vagrant ubuntu/trusty64.  Edit the vagrantfile and Below “Vagrant.configure(“2″) do |config|” add: = “ubuntu/trusty64”
config.vm.box_version = “20160926.0.1”

exit your editor and do

vagrant up
vagrant ssh

Then you have your ubuntu server to setup how you want.

Example of setting up PHP 7 dev vagrant:

Provisioning w/ external shell script:

  config.vm.provision "shell", path: ""

in you could run an update and install of apache, php:

sudo apt-get -y update
sudo apt-get -y install apache2 php7 libapache2-mod-php7

Give a network IP address "private_network", ip: ""

Want to do this on a power System?  Well VirtualBox doesnt appear to support powerpc so looks like you have to use powerkvm instead.

How to use Vagrant with PowerKVM