The ability to deploy web-based applications continues to be a major focus of many organizations. The deployment stack based on open-community applications is the LAMP stack (LAMP stands for the Linux operating system, Apache Web Server, MySQL database server, and PHP scripting language). The LAMP stack, sometimes referred to as the open-source web platform, has gained popularity among web developers as a low-cost, reliable platform for web-based applications. A large body of LAMP-based applications is available in the open community to provide functions such as blogs, bulletin boards, e-commerce, portals, and customer relationship management.
Until now, System i customers who wanted to deploy LAMP-based solutions had to implement a Linux partition. Last year's incorporation of PHP into i5/OS and this year's announcement of MySQL for i5/OS mean that System i customers can now implement an i5/OS variant of the LAMP stack, referred to as iAMP (i5/OS, Apache, MySQL, PHP). With iAMP, customers can leverage the wide portfolio of open-community applications directly in i5/OS.
This article takes you through the steps required to implement the iAMP stack in i5/OS. In addition to setting up the iAMP stack, I show you how to install an open-community application.
To help you understand what needs to be installed, let's look at the structure of the iAMP stack (Figure 1). As you can see, Apache, MySQL, and PHP need to be set up in the Portable Application Solutions Environment (PASE) environment.
The iAMP stack can be implemented only in V5R4 and requires a number of LPPs installed in i5/OS, as Figure 2 shows. Note that the requirement for V5R4 is because only V5R4 supports MySQL. If you intend to use only the PHP support (typically to develop your own applications against i5/OS resources), you can also implement on V5R3 Zend Core is supported on both releases.
Zend Core is the engine that provides the ability to execute PHP applications in i5/OS. The Zend Core installation includes the following:
"PHP Installation, Configuration, and Setup," page ProVIP 33, provides details about Zend Core. For the purposes of this article, let me summarize the Zend Core installation here:
Installing Zend Core in i5/OS provides us with half of the iAMP stack (i.e., Apache and PHP). At this point, you could develop your own web-based applications against i5/OS resources. However, if you want to deploy existing open-community applications without change, you must install MySQL, because most open-community PHP applications use MySQL as the data repository for the application.
As with PHP, MySQL for i5/OS runs in the PASE environment. Figure 3 shows an overview of this architecture. The steps for installing MySQL are similar in many respects to the steps for installing Zend Core. To begin with, you need to download MySQL for i5/OS. There are two versions, a community server version and an enterprise version. The difference between these two versions is in the support model and licensing of the product. This article discusses the implemention of the community server version, a freely available version of the open-community database engine.
The download page for the MySQL Community Server is at dev.mysql.com/downloads/mysql/5.0.html. Perform the following steps to download the MySQL package:
After you have downloaded the zip file to your PC, you are ready to perform the MySQL installation. You need to upload the MySQL save file to i5/OS, restore the MySQL installation library, and then perform the actual MySQL installation. First, upload the save file to i5/OS:
The uploaded zip file contains an i5/OS library that includes a tar file of the MySQL files along with an installation program. You use the RSTLIB command to restore the library. As an example:
RSTLIB SAVLIB(MYSQLINST) DEV(*SAVF) SAVF(MYSQL) MBROPT(*ALL) ALLWOBJDIF(*ALL)
After you restore the library, you are ready to perform the actual installation of MySQL by issuing the following command:
MYSQLINST/INSMYSQL
Press F4 to display the following prompts for the MySQL installation (Figure 4). The responses provided to the prompts represent the following information to the installation program:
A typical MySQL installation uses the default responses to the prompts. On most i5/OS systems, the installation runs for several minutes without any messages or user interaction. After the installation is completed, a number of diagnostic messages are displayed.
Remember that MySQL runs in the PASE environment. Perform the following steps to start the MySQL server:
To execute PHP programs that use the MySQL database engine, you need to enable the MySQL extensions in Zend Core. You can do this in one of two ways either by editing the Zend Core configuration file directly or by using the web-based administration interface.
First, let's look at making the changes directly to the configuration file. By default, the Zend Core configuration file (named php.ini) is in the \usr\local\Zend\core\etc directory. You need to edit the file and look for the following two entries:
;extension=mysql.so ;extension=mysqli.so
The first extension is for MySQL, and the second extension is for MySQL Improved. You need to enable both extensions by removing the semicolon at the start of the line. After the extensions have been enabled, restart Zend Core through the Zend Core Setup Utility (GO ZENDCORE/ZCMENU).
The other way to enable the extensions is with the web-based Zend Core Administration interface. You can start the interface by directing a web browser to http://iseries:89/ZendCore. After you provide the password for the administration interface, select Configuration|Extensions and scroll down the list until you see the MySQL extensions (Figure 5).
To enable the extensions with this interface, click the extension icon (it's the second icon on the right side). The extension indicator needs to be at the top of the extension indicator. When the extension has been enabled, save the settings by clicking Save Settings and restart the server by clicking Restart Server.
At this point, you have actually implemented your own i5/OS variant of the LAMP stack. The three components Apache, MySQL, and PHP (Zend Core) are all installed in the PASE environment and ready for you to use to deploy applications. Let's spend the rest of the article taking a look at how to use the stack to deploy open-community applications.
A large number of open-community applications are just waiting for you to deploy them in i5/OS. They are available from such sites as PHPFreeks (phpfreeks.com), SourceForge (sourceforge.net), HotScripts (hotscripts.com), PHPJunkyard (phpjunkyard.com), and PHPFreebies (php-freebies.com). Open-community applications fall into a large number of categories, including blogs (in which entries are entered in chronological order and displayed in reverse chronological order), portals (which offer a broad array of resources and services), e-commerce sites (which facilitate purchase of products across the Internet), and wikis (which let users freely create and edit web page content), just to name a few.
The method for implementing open-community applications using the iAMP stack can generally be broken into the following steps:
Keep in mind that many of the files that you download for the open-community applications will have two levels of compression. Typically, you will have to uncompress the first level of compression before you upload it to the IFS. Many compression utilities are available one that I recommend is 7ZIP (7-zip.org/download.html).
Let's finish our discussion by looking at deployment of an actual open-community application. As an example, let's install the phpMyAdmin program (Figure 6), which you can use to manage the MySQL environment from a web browser. Here are the steps to implement the application:
At this point, you are ready to access the phpMyAdmin application by pointing a browser to http://systemi:89/phpMyAdmin.
This article has walked through the steps for establishing your own open-community web development/deployment stack with Zend Core and MySQL. Additionally, I covered the installation of an open-community application to show the ease with which this support lets you leverage the wide collection of readily available open-community applications that you can now implement directly in i5/OS. If you follow these steps, it is likely that you can have your own iAMP stack running on your system in less than 60 minutes.
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. At that center, he provides education and enablement services for open-source-related technologies on System i, including Linux, MySQL, and Zend's PHP.