BreadcrumbHomeResourcesBlog Installing Community PHP On IBM I January 8, 2020 Installing Community PHP on IBM iPHP DevelopmentModernizationBy Erwin EarleyTable of ContentsHow to Install Community PHP on IBM iNext StepsTable of Contents1 - How to Install Community PHP on IBM i2 - Next StepsBack to topHow to Install Community PHP on IBM iNow that community PHP is available for IBM i, you may be wondering how to set up the open source operating system on the platform. Unlike the single-step install (RSTLICPGM) that delivers a certified PHP stack as part of Zend Server setup, community PHP requires installation and configuration of multiple packages.This blog will provide a step-by-step approach to the installation of a development/solution stack based on community PHP, related packages, and extensions. Along the way, commands will be used to validate the various components of the community stack. For purposes of this blog, we used a container on an IBM i system. See Getting Started with Community PHP blog for details on how to establish a container.Steps to Set Up the Community PHP StackDefine package repository (log for further instruction).Installation of the php-core package.Installation/Configuration of Web Server.Configuration (and possibly installation) of database drivers.Community PHP Installation InstructionsAs mentioned above, community PHP and its extensions are provided as a number of separate RPMs. The first two RPMs to install are php-common and php-cli. The base packages for community php are 'php-common' and 'php-cli'. The 'yum install' command will be used to install these packages:yum install php-common php-cliThe system will output messages indicating the actions that will be taken:Setting up Install ProcessResolving Dependencies--> Running transaction check---> Package php-cli.ppc64 0:7.3.12-0 will be installed---> Package php-common.ppc64 0:7.3.12-0 will be installed--> Finished Dependency Resolution Dependencies Resolved ======================================= Package Arch Version Repository Size=======================================Installing: php-cli ppc64 7.3.12-0 repos.zend.com_ibmiphp 12 M php-common ppc64 7.3.12-0 repos.zend.com_ibmiphp 290 k Transaction Summary==========================================Install 2 Packages Total download size: 12 MInstalled size: 57 MIs this ok [y/N]:Type 'y' and press the <ENTER> key to install the specified packages. Diagnostic messages such as the following will be output to indicate the actions taken and the completion of the installation:Downloading Packages:php-cli-7.3.12-0.ibmi7.2.ppc64.rpm | 12 MB 00:00 Running Transaction CheckRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : php-common-7.3.12-0.ppc64 1/2 Installing : php-cli-7.3.12-0.ppc64 2/2Installed: php-cli.ppc64 0:7.3.12-0 php-common.ppc64 0:7.3.12-0 Complete!Installation of PHP can be confirmed by running the 'php' command with the '-v' flag:php -vThe version information for php should be displayed:PHP 7.3.12 (cli) (built: Dec 1 2019 17:37:53) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.3.12, Copyright (c) 1998-2018 Zend TechnologiesThe installation shown above installed the core PHP engine as well as the Command Line Interface (CLI). At this point, enough has been installed that we can now validate the functionality of PHP. One way to validate would be write a short PHP script and include the path to the php executable:#!/QOpenSys/pkgs/bin/php -q<?php echo "Hello World';?>If you have explored PHP in the past, then you may recognize the starting php tab (<?php) as well as the close tag (?>). The 'echo' statement is used to generate output. The first line in the example, and more specifically the first two characters, which is the remainder of the line provides a path to the executable to be used to interpret the rest of the file. When the file is executed it will generate the indicated output (i.e., 'Hello World').If you don't want to create a file, then you can use the CLI directly by entering:/QOpenSys/pkgs/bin/php -qThe above will place you in the CLI of PHP and everything entered will be interpreted by the PHP engine until the <CTRL><D> key sequence is entered. At this point you can simply enter the equivalent of a PHP script such as the one shown above (If you want to get a little more creative with the validation, instead of a simple 'hello world' string, execute the 'phpinfo()' function to output a variety of information related to the PHP environment.While the Command Line Interface of PHP can be useful for certain tasks, it is likely that you will actually want to use PHP with a web server. Back to topNext StepsStay tuned for our next blog on the guidelines to the configuration of Apache for PHP and configuration of NGINX for PHP. If you’d like to go through this process with an expert, the team at Zend by Perforce is ready to help you!Contact UsAdditional Resources101 Guide: Developing Web Applications with PHPBlog: Unleash Your DB2 Databases with PHPBlog: What Is a PHP Function?Blog: PHP Server Basics Back to top
Erwin Earley IBM Champion | Former - Senior Solutions Consultant, Zend, Perforce Software As an IBM champion, Mr. Earley has been recognized as a leader in the IBM i community and offers more than 20 years of experience helping customers to implement solutions on the platform. His expertise includes using PHP, MariaDB, Docker, and Chef for creating modern enterprise solutions that run on IBM i, as well as PowerVC for cloud deployments and virtualization management. Mr. Earley is a frequent speaker at global technology conferences, and he has authored numerous articles on Linux, PHP, virtualization, systems management, and open source solutions and concepts.