decorative image for blog on installing zendphp on ibm i
March 11, 2021

One and Done: Installing ZendPHP on IBM i


Late last year I wrote a blog showing the ease of getting PHP on the platform with Zend Server as well as the complete integration of PHP with the rest of the system (i.e., Apache, Db2, ILE programs and objects). With our recent release of ZendPHP for IBM i, you may be wondering if we still followed the same one-and-done approach to installation... and the answer is a resounding yes! 

While the installation method has changed from Licensed Program Product (LPP) to RPM Package Manager (RPM) the same integration aspects of the product are there. Read on as I walk you through the simplicity of installing ZendPHP on IBM i, as well as Db2 and ILE integration.

Back to top

How to Install ZendPHP on IBM i

Let’s begin with the installation. To start, as I mentioned in the introduction, ZendPHP is provided as a set of RPM packages and as such it follows the installation and update processes of other open-source packages.  The packages reside in what is referred to as a package repository, and it is from there that the package is installed.  There are a number of setup steps that you could perform manually such as defining the package repository on your system, setting a search path for executables, and establishing a home directory, or you could leverage a setup/installation script that we provide. 

Setup/Installation Script

To obtain the script, you register for ZendPHP and we send installation instructions that detail how to retrieve and execute the script to you.  Keep in mind that the package is being installed in the PASE environment using the open-source ecosystem (OSE) so you would need to have the open source bootstrap already installed – if you need more information on that, reach out to us!

Installing ZendPHP

Once the bootstrap is installed you are ready to install ZendPHP.  To access the PASE environment you will need to establish a terminal session either through QP2TERM (not recommended) or via SSH (recommended).  SSH is the recommended approach as it adheres more closely to what open-source packages expect with regards to items such as process identification/environment and has a number of useful features including the bash shell with command history and file-name completion.  You are now ready to install ZendPHP – navigate to the directory where you placed the ‘’ script that was obtained via the registration link and execute it as follows:


You will observe a number of messages displayed indicating various packages being installed.  After a few minutes the command prompt is redisplayed, and the installation is complete.  Now let’s see if it actually worked.

Recall that I indicated earlier that one of the integration points provided with ZendPHP is integration with the Apache web server, so let’s check that out first.  The Apache configuration (which can be found at /www/zendphp/conf/httpd.conf) is configured with the DocRoot (the default location for scripts) as /www/zendphp/htdocs so first let’s put a simple PHP script named hello.php in that directory:

        echo "Hello world - ZendPHP is sure easy to install!!!";

Executing the script can be accomplished one of two ways – if you want to simply execute it from the terminal window then you can use the PHP CLI as follows:

php hello.php

Assuming no typos are present in the script, then you should receive the following output:

Hello world - ZendPHP is sure easy to install!!!

But that doesn’t really prove that ZendPHP is integrated with Apache!  To prove that, let’s run the same script from a web-browser as follows:

http://<IBM i system>:10080/hello.php

The following output should be displayed in the web browser:

screenshot showing successful confirmation of zendphp install on ibm i

One thing to note here is the port number. The default port (or virtual host) that ZendPHP uses is 10080; however, if an installation of Zend Server is also on the system then a different port number will be used which can be found in the Apache configuration file identified earlier. Why is this important? Put simply, it means that ZendPHP can be installed alongside Zend Server in the same way that simultaneous installations of Zend Server has been supported for many releases.

Db2 Integration

Up to this point we have shown that the installation of ZendPHP is accomplished with a single command and that Apache integration is part of the installation.  Let’s move on and show the Db2 integration.

Place the following script (call it something like db2test.php) in the docroot (/www/zendphp/htdocs):

        $conn = db2_connect('*LOCAL', '', '');
        $result = db2_exec($conn, "SELECT * FROM QIWS.QCUSTCDT");
        $firstRow = db2_fetch_assoc($result);
        echo print_r($firstRow, true);

The script leverages the QCUSTCDT schema that is delivered with IBM i.  Like the previous script, this script can be run either through the CLI or via the web server.  I went ahead and ran it through the CLI as follows:

php db2test.php

Which resulted in the following output:

    [CUSNUM] => 938472
    [LSTNAM] => Henning 
    [INIT] => G K
    [STREET] => 4859 Elm Ave 
    [CITY] => Dallas
    [STATE] => TX
    [ZIPCOD] => 75217
    [CDTLMT] => 5000
    [CHGCOD] => 3
    [BALDUE] => 37.00
    [CDTDUE] => .00

So, now we have shown that Db2 integration is delivered with ZendPHP.

ILE Integration

The final item to show is ILE integration.  Let’s place the following script (call it iletest.php) into the docroot (/www/zendphp/htdocs) directory:

require_once '/QOpenSys/pkgs/share/zendphp/libraries/xmltoolkit/1.8.5/ToolkitService.php';

$obj = ToolkitService::getInstance();
$rows = $obj->CLInteractiveCommand('DSPLIBL');
echo '<pre>' . print_r($rows, true) . '</pre>';

Like the other scripts, this script can be run either through the CLI or through the web-browser and again I chose to run it through the CLI as follows:

php iletest.php

This generated the following output, showing that the CL command DSPLIBL was executed:

    [0] =>  5770SS1 V7R4M0  190621    Library List     2/09/21  6:14:46     Page   1
    [1] =>                           ASP
    [2] =>    Library     Type       Device      Text Description
    [3] =>    QSYS        SYS                    System Library
    [4] =>    QSYS2       SYS                    System Library for CPI's
    [5] =>    QHLPSYS     SYS
    [6] =>    QUSRSYS     SYS                    System Library for Users
    [7] =>    QGPL        USR                    General Purpose Library
    [8] =>    QTEMP       USR
    [9] =>                           * * * * *  E N D  O F  L I S T I N G  * * * * *

That’s it!

Back to top

Final Thoughts

Just like Zend Server, ZendPHP supports a one-and-done approach to installation as well as delivery/integration of key aspects of using PHP on the IBM i platform.  This blog has demonstrated the ease of installation of ZendPHP along with the ability to access Db2 data and ILE programs and objects “out-of-box”.

One closing thought: as I indicated in my earlier blog on ZendPHP, ZendPHP is another offering from Zend that delivers PHP to the platform – it is not a replacement of the full-featured Zend Server.  But it is a viable option for those who are looking to use a PHP stack without the application server functions that Zend Server delivers.  In a future blog I will show the same ease of installation of Zend Server 2020 which is also packaged as an RPM instead of the predecessor LPP.

Try ZendPHP Today

Ready to give ZendPHP a spin? Click the button below to register for your free download.

Try ZendPHP Free

Additional Resources

Back to top