This article covers the installation of the Zend products to support PHP on i5/OS. Specifically, I show the installation of Zend Core, the PHP engine, and Zend Studio the Integrated Development Environment (IDE) for PHP.
Zend Core is the engine that supports PHP in i5/OS. Zend Core runs in the Portable Application Solutions Environment (PASE). Figure 1 shows the architecture of Zend Core in i5/OS. Before I discuss the architecture represented by the diagram, however, let me introduce a sample web page with PHP content.
As Figure 2 shows, a web browser issues a request to a web server (in this case, the Apache-powered i5/OS HTTP Server). In Figure 1, any web request to the i5/OS HTTP Server that specifies port 89 (e.g., http://i5_name:89) is forwarded to the Apache web server running in the PASE environment (Apache is installed in PASE as part of the Zend Core installation). The Apache web server in PASE works through the HTML until it encounters a PHP tag (<?php in Figure 2). At this point, the PHP code is sent on to the PHP engine (in this case, Zend Core in the PASE environment), which then processes the code until it encounters a close PHP tag (?>). The output from processing of the PHP code is sent back to the web server as HTML output, which is then forwarded as a response to the web browser for rendering. Figure 3 shows the result of processing the code sample in Figure 2 through the PHP engine.
In this case, processing the PHP simply generates an output line that the web browser renders. As Figure 1 shows, PHP is a server-side language; in other words, the PHP engine on the server interprets the PHP code. Also, the PHP code has access to server-side resources (e.g., database resources). In i5/OS, access to server-side resources is provided through the I5_COMD job installed in the ZEND subsystem.
Before I talk about the installation of Zend Core, let me summarize the components that will be installed:
The HTTP Server in i5/OS will be configured to forward requests on port 89 to the Apache web server in the PASE environment.
The easiest way to get Zend Core (and Zend Studio for that matter) is to register at Zend's website (zend.com). After you provide basic contact information, you gain access to the i5/OS channel, from which you can download Zend Core for i5/OS (I recommend that you download version 2 of the product). The downloaded zip file contains a number of files. You need to upload the save-file to i5/OS. You can accomplish this in several different ways, but I typically use FTP to upload the file directly into QGPL. Figure 4 shows an example FTP stream.
After you upload the save-file to i5/OS, it is a simple matter to run the Restore Licensed Program (RSTLICPGM) command and answer a few prompts. Here is the format of the command:
RSTLICPGM LICPGM(1ZCORE5) DEV(*SAVF) SAVF(QGPL/ZCORE)
At this point, a number of files are written into the IFS, after which the first prompt of the installation is displayed. The first screen is just a welcome screen, so press Enter to display the license agreement screen. Press Enter again to accept the license agreement and display a prompt for the Web Administration Console password. The password entered here is user defined and will be used to validate access to the web-based administration tool for Zend Core (I show how to access this tool later).
Zend Core supports the ability to obtain updates from the Zend Network. Access to the Zend Network requires an authenticated user ID and password (this is the user ID and password that you defined when you registered for the Zend products on the website). After you input your Zend Network user ID and password, the installer finishes setting up the environment for Zend Core.
Probably the simplest way to test the installation of Zend Core is to attempt to access the Zend Core test page. Point a web browser to port 89 of your i5/OS (e.g., http://systemi:89). You should see a simple Welcome web page. Click the Zend Core administrative interface link to access the web-based management interface.
Zend Core includes a 5250 menu for working with the status of the Zend Core and Apache servers as well as the I5_COMD job, which runs in i5/OS to respond to requests for server-side resources from PHP. Access the tool by issuing the following command in a 5250 session:
GO ZENDCORE/ZCMENU
From the next menu, you can reset the password for accessing the web-based administrative interface (I discuss this interface later), obtain and install updates for Zend Core, and collect information concerning Zend Core for Zend support. You can also access the Service Management menu, which provides the ability to work with the status of the Zend Core and Apache Servers as well as the I5_COMD service.
Let's take a quick look at the web-based administrative interface provided for Zend Core. As I mentioned earlier, you can access the interface by clicking the Zend Core administrative interface link from the Zend Core test page. You can also get to the interface by pointing your browser to http://systemi:89/ZendCore. Either way, you will be prompted for the password that you defined during installation. Enter your password to go to the System Overview page (Figure 5).
The overview page provides a variety of information, including version numbers of the Apache Server and Zend Core as well as data about the number of processes and threads being executed by the web server. One interesting feature of the administrative interface is the ability to configure allowable clients to debug code on the server. To configure Zend Core to accept debug from clients, select Configuration and then Zend Studio Server on the Zend Studio Server Settings page (Figure 6).
Use the Allowed Hosts entry to define the network address or range of network addresses allowed to perform remote debug of PHP code running on the Zend Core server. When the definition is complete, select Save Settings.
Zend Studio is the IDE that Zend provides for the development of PHP code for i5/OS. Zend Studio is available for three different clients: Windows x86, Linux x86, and Mac OS X Power.
The first step of the installation is to download the product from the i5/OS channel on Zend's website. When the download is complete, double-click the file to start the installation process. The installation of Zend Studio is similar to other Windows applications. Here is a summary of the installation steps:
The installation typically takes less than a minute.
Let's look at some of Zend Studio's features. First, start the Zend Development Environment (Figure 7). You can write or edit PHP code in the middle area, output a debug message in the pane on the right, and use the pane on the left to explore the file system, work with projects, or view SQL resources. One of the coolest features of the development environment is the ability to connect to an SQL resource directly from the environment so that you can view the database structure(s) that you are writing code against. To work in the SQL view, first select the SQL icon in the view display on the left side. After the view has switched, you are ready to define a new SQL resource by clicking the Add SQL icon (the disk with the plus sign) to display the Add SQL Server dialog box (Figure 8).
You should complete the form with the requested information for the SQL connection (make sure to select DB2/400 in the Server Type drop-down box). When the definition is complete, click OK to complete the connection to the SQL resource. After the connection is done, you can use the SQL view on the left side of the Zend Studio workspace to display different aspects of the database resource (Figure 9).
Erwin Earley is an advisory software engineer in the IBM lab located in Rochester, Minnesota, and heads up the Open Source Technologies Center of Competency for System i within the System i Technology Center.