PHP Installed on IBM i - the Nickel Tour

Preview:

Citation preview

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

1

PHP installed on IBM i The Nickel TourRod Flohr, IBM i Support Specialist

ZendCon 2016 linkhttps://legacy.joind.in/19478

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

2

Who am I, and Why Should You Trust Me?

My name is Rod Flohr, and I have been providing support for Zend products on IBM i for the last decade. In Support, we do not all know everything about the product, although we try to know as much as we can. What we do is investigate, classify, and explain. We do a lot of explaining. Fortunately, I like to explain things. I might even go a little overboard from time to time. Here is a photograph wherein I attempt to explain the operation of an iPhone to a cat:

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

3

The Nickel Tour – Taking a look around• What is a Nickel Tour?

– The Nickel Tour is an informal tour– It is a casual orientation, not an in depth education– When I do a WebEx with a customer, I often like to show them the

locations of various objects placed by the Zend Server installation, and how they all relate. I started calling this the Nickel Tour.

– This is an administrative tour. This is about where things are installed, and how they interact. There will be no PHP coding.

• Why take the Nickel Tour?– It helps to know where things are, and it helps to know that things

exist.– Provides a foundation for understanding complicated systems or

places.• So come on in. Let me show you around.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

4

PHP on IBMi, illustratedIFS PASE IBM i The

NetTCP/IP

(address)Apache (port)

FastCGI(handler)

PHP Parent

Zend Server Components

PHP Child (many)

Ibm_db2Toolkitmysqli

MonitorJob Queue

Deploymentprngd

Java Bridge

Content

DB2

Jobs, Library Objects

PHPhtmlcssjs

pdfxlsetc

ConfigsApacheFastCGI

PHP

DataMariaDB

MariaDBServer

http requesthttp response

*PGM*CMDSPLF

*DTAARALogs,

Sessions, etc.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

5

Installing Zend Server

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

6

Install Zend Server to get PHP on IBM i• The way to get PHP on IBM i is to install Zend Server

– IBM includes a Zend Server installation file with IBM i OS, but don’t use it. It is almost always out of date.

– Download from: http://www.zend.com/en/products/server/downloads#IBM i

– Always use the RSTLICPGM installer for new installations or migrations

– Always use the APYPTF installer for upgrades– Instructions are included in the download package– Additional tips: https://support.zend.com/hc/en-us/articles/203501993

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

7

Download from this page

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

8

Unzip the downloaded file

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

9

Create the save file first!

1. Log on to the IBM i system with a user profile of *SECOFR user class with all the special authorities. Create a SAVF in QGPL under the name zendphp7. This can be done by running the following command: CRTSAVF FILE(QGPL/zendphp7) TEXT('Zend Server 9 product save file')

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

10

CRTSAVF command

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

11

FTP the SAVF – verify FTP is up

2. Transfer the package by binary FTP to the SAVF zendphp7 in QGPL. This can be done by executing the following steps: a. Verify that FTP is running on your IBM i system by running the following command and looking for 'FTP' or '21' in the Local Port column: NETSTAT *CNN

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

12

Use netstat *cnn to verify FTP

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

13

Netstat unsorted display

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

14

Use F13 to sort the display

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

15

Netstat sorted by local port

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

16

Netstat after F14 to show port numbers

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

17

FTP the SAVF – set current directory

b. Open a command prompt and change the directory to the directory that contains the files you extracted from the ZIP file.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

18

Copy the current directory

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

19

Type cd, a space, then paste

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

20

FTP the SAVF – FTP session

c. Run the FTP command, specifying the name of your i5/OS system. e.g.: ftp IBM_i_system_name/TCP addressd. If requested, enter a valid user profile and password. Enter the bin command to specify a binary transfer.e. Transfer the save file to the IBM i system by running the following command: put zendphp7.savf qgpl/zendphp7

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

21

FTP the SAVF – FTP session

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

22

DSPSAVF to make sure it is a valid SAVF

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

23

Verify prerequisites

3. Before installing Zend Server for IBM i, please verify that the prerequisite IBM software is installed.

You can find a listing of the required software at: http://files.zend.com/help/Zend-Server-IBMi/zend-server-ibmi.htm#i5_installing_zend_server.htm

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

24

Verify prerequisites

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

25

Verify prerequisites – go licpgm – option 10

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

26

Verify prerequisites – 5733SC1 release check

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

27

RSTLICPGM to install Zend Server 9

4. When the SAVF is loaded into the IBM i QGPL library, return to your 5250 session and run the following command (choose one):

a. Silent installation: SBMJOB CMD(RSTLICPGM LICPGM(7PHPZND) DEV(*SAVF) SAVF(QGPL/zendphp7))

b. Interactive installation: RSTLICPGM LICPGM(7PHPZND) DEV(*SAVF) SAVF(QGPL/zendphp7)

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

28

Optional CHGJOB step

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

29

RSTLICPGM to install Zend Server 9

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

30

RSTLICPGM – Welcome!

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

31

RSTLICPGM – EULA – Please read

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

32

RSTLICPGM progress messages

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

33

RSTLICPGM – Success!

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

34

Verify Success – go licpgm – option 10

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

35

go zendphp7/zsmenu

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

36

Library objects are in ZENDPHP7

• The library for Zend Server 9 is ZENDPHP7. For version 6-8, it is ZENDSVR6. For version 5, it is ZENDSVR.

• Library objects include menus, subsystem descriptions, job descriptions, job queue descriptions, various controller programs (start and stop, etc.), XMLSERVICE (Toolkit service), data areas, and so on.

• There is also an Autostart Job Entry added to subsystem description QSYSWRK. This entry starts the ZENDPHP7 subsystem, the Zend Server component jobs, and the ZENDPHP7 Apache instance. The entry is named ZS9_STRSBS.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

37

Access the Zend Server User Interface (UI)

• The Zend Server User Interface provides a graphical control center for PHP and Zend Server components accessible from a web browser.

• The internet address for your Zend Server UI is in this format:http://<your IBM i IP address>:10091

• For example, if your IBM i is assigned address 162.209.30.134:http://162.209.30.134:10091

• When you go to this address in your browser, /ZendServer/ will be appended:http://162.209.30.134:10091/ZendServer/

• The first time you visit the UI, you will encounter some set up pages.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

38

First UI access – License Agreement

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

39

First UI access – Profile always Production!

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

40

First UI access – Set admin password

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

41

First UI access – Deploy Libraries

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

42

First UI access – Summary – All done!

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

43

Zend Server UI – Welcome!

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

44

TCP/IP and Apache

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

45

TCP/IP and ApacheIFS PASE IBM i The

NetTCP/IP

(address)Apache (port)

FastCGI(handler)

PHP Parent

Zend Server Components

PHP Child (many)

Ibm_db2Toolkitmysqli

MonitorJob Queue

Deploymentprngd

Java Bridge

Content

DB2

Jobs, Library Objects

PHPhtmlcssjs

pdfxlsetc

ConfigsApacheFastCGI

PHP

DataMariaDB

MariaDBServer

http requesthttp response

*PGM*CMDSPLF

*DTAARALogs,

Sessions, etc.

You are here

And here

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

46

TCP/IP – IP addresses (IPv4)

• The IP address consists of four bytes, in decimal (range 0 to 255), separated by periods. Here is an example:162.209.30.134

• The IP address identifies the server computer. Services on that server may each use a different port. The port is a 16 bit number (range 0 to 65535). It may be appended to the IP address after a colon:162.209.30.134:10091

• IP addresses on the Web can be given Domain Names, which are easier to remember than numbers:www.zend.comzend.com

• You can ping a domain to discover its IP address (provided it will respond to pings).

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

47

TCP/IP – IP addresses telephone analogy• The IP address is like a phone number, and the port is like a phone extension.• Like a company with many phone extensions, the server will have one or a

few IP addresses. Like an employee or department with an extension, each service will respond on a specific port number. Also, an employee can answer more than one extension, and a service may use more than one port.

• Two services on the same IP address cannot share a port.• Unlike an extension, a service can have many conversations active at the

same time on a single port. The service listens to the port for any traffic. It is like the phone is always off the hook, and anyone can connect.

• Domain Names are mapped to IP addresses by a Domain Name Server (DNS), which itself is accessed at an IP address.

• The DNS is like a Contact List on your smart phone. You can call a person without knowing their number.

• Multiple names can be assigned to the same number. Apache can sort them out using name entered (like caller ID) and Virtual Hosts definitions.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

48

TCP/IP – Default Ports• For many TCP/IP services, there is a default port. If the service is listening

on the default port, the port does not have to be specified on the request. For example, the default port for http is 80, so these are the same:http://www.zend.com == http://www.zend.com:80

• Some common port defaults:http 80https 443ftp 21ssh 22telnet 23

• Use WRKSRVTBLE to see reserved port numbers on IBM i.• The Internet Assigned Numbers Authority (IANA):http://

www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml

• https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

49

Apache – your web site, at your service• Apache is a service that handles http and https requests. It is your web

server.• On IBM i you can have many instances of Apache. Each instance is a

service that listens on specified port(s) that cannot be shared.• The typical request begins when a browser user clicks a link or types in a

URL. If the IP address matches your server, the internet will send that request to your server, and TCP/IP will give it to a service based on the port.

• The http request will typically be for a file. Apache locates the file on your server and returns it to the requester. If it is an html file, the web browser can display it as a web page.

• The request may have parameters to request a dynamic web page. This web page will be created on demand by a process on the server, using some language like PHP, Python, Node.js, Ruby, Java, and so forth.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

50

Apache – the Zend Server instance

• The name of the Zend Server instance of Apache depends on the release:Version 9 – ZENDPHP7Version 6, 7, and 8 – ZENDSVR6Version 5 – ZENDSVR

• On IBM i, Apache instances are typically stored under the /www directory. The Zend Server 9 instance is found at /www/zendphp7

• There are three subdirectories:/www/zendphp7/conf – Apache and FastCGI configurations/www/zendphp7/htdocs – Content/www/zendphp7/logs – Logs, and the FastCGI socket

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

51

Apache config file httpd.conf

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

52

ZENDPHP7 httpd.conf file• The ZENDPHP7 Apache instance configuration is defined in:

/www/zendphp7/conf/httpd.conf• You can manage your Apache configuration in a web browser at:

http://<your IBM i IP address>:2001/HTTPAdmin/(Apache instance ADMIN must be active)

• You can also edit the httpd.conf file in Navigator. Right click Integrated File System, select properties, and set “Enable edit menu option for” to “All files”. Now, the Edit option will never be grayed out for any file. Please remember never to edit a binary file!

• Like all configurations, ALWAYS make a back up copy before changing.

• Yes, ALWAYS!

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

53

Enable all file editing in Navigator

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

54

Zend Server instance listens on 3 ports• When the Zend Server Apache instance is active, it listens on 3

ports. TCP/IP will direct traffic for those ports to the Zend Server Apache instance.

• ZENDPHP7 (Zend Server 9) ports:10090 – Default port for applications10091 – Zend Server User Interface10093 – User Server (internal use by Zend Server components)

• ZENDSVR6 (Zend Server 6, 7, 8) ports:10080 – Default port for applications10081 – Zend Server User Interface10083 – User Server (internal use by Zend Server components)

• Defined in the httpd.conf file

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

55

Listen Directives in httpd.conf• The Listen directives can be listed anywhere in the configuration. The Listen

directives for ports 10091 and 10090 are listed near the top:Listen *:10091NameVirtualHost *:10091Listen *:10090NameVirtualHost *:10090

• The Listen directive for port 10093 is found by the Virtual Host definition for the User Server:Listen 127.0.0.1:10093NameVirtualHost 127.0.0.1:10093<VirtualHost 127.0.0.1:10093>

• Directive placement in the Apache configuration is arbitrary so long as the directive is in the correct container. It is best to be consistent in placement to make things easier to understand.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

56

PHP – your web page machine• PHP receives a request from Apache, and uses the information in the request

to construct a web page. It then passes that web page back to Apache.• Apache receives the web page from PHP and sends it back to the requester,

just as if Apache had retrieved a file instead of asking for PHP to create one.• So how does Apache know when to get a file by itself, and when to ask PHP to

create one?

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

57

FastCGI will handle that for you• So how does Apache know when to get a file by itself, and when to ask

PHP to create one? Short answer - .php suffix• Apache can handle requests itself, or pass requests to a handler.• “A "handler" is an internal Apache representation of the action to be

performed when a file is called.”ref: http://httpd.apache.org/docs/current/handler.html

• The FastCGI handler needs the QZFAST module to be loaded:LoadModule zend_enabler_module /QSYS.LIB/QHTTPSVR.LIB/QZFAST.SRVPGM

• This allows the handler to be set:# zend fastcgiAddType application/x-httpd-php .phpAddHandler fastcgi-script .php

• The AddHandler directive sets the handler for the given extension, which is .php .

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

58

FastCGI sets the environment for PHP• The FastCGI configuration sets up the PASE environment for PHP.• It defines the path to the runtime, the library path, how many parent and child

processes, php config file location, timeouts, and more.• Most of it is on one line, and must be on that one line, and not as it is shown here:Server type="application/x-httpd-php" CommandLine="/usr/local/zendphp7/bin/php-cgi.bin" StartProcesses="1" SetEnv="LIBPATH=/usr/local/zendphp7/lib" SetEnv="PHPRC=/usr/local/zendphp7/etc/" SetEnv="PHP_FCGI_CHILDREN=10" SetEnv="PHP_FCGI_MAX_REQUESTS=0" ConnectionTimeout="30" RequestTimeout="60" SetEnv="CCSID=1208" SetEnv="LANG=C" SetEnv="INSTALLATION_UID=100313092679" SetEnv="LDR_CNTRL=MAXDATA=0x40000000" SetEnv="ZEND_TMPDIR=/usr/local/zendphp7/tmp" SetEnv="TZ=<PST>8<PDT>,M3.2.0,M11.1.0”

• A separate line tells where to place the socket.IpcDir /www/zendphp7/logs

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

59

PHP runs in PASE, controlled by batch jobs

• On IBM i, programs compiled for AIX run in PASE processes• A PASE process can be controlled by a batch job. Typically, a CL

program calls QP2SHELL, which is the PASE shell.• When PASE processes run in batch, the stdout and stderr output

is spooled to the job default, usually QPRINT. This is where you can find normal output and error messages written by a program running in PASE. These are often overlooked when troubleshooting.

• On the next slide we will see the call stack for a PHP child process that is at rest.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

60

PHP Child Process, Resting

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

61

Apache instances run in QHTTPSVR sbs

• To view the status of your Apache server instance jobs:wrkactjob sbs(qhttpsvr)

• One instance of Apache has many jobs:Function Status What it is forPGM-QZHBMAIN SIGW MainlinePGM-QZSRLOG SIGW Logs (Two of these, access and

error)PGM-QZSRHTTP SIGW Apache (HTTP Server)PGM-zfcgi SELW FastCGIPGM-php-cgi.bi THDW PHP Parent (one of these, by

default)PGM-php-cgi.bi TIMW

TIMAOthers

PHP Child (many of these, 10 by default) This is where the PHP scripts run.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

62

wrkactjob sbs(qhttpsvr)

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

63

IBM Web Administration for i • http://<your IP address>:2001/HTTPAdmin/

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

64

Apache Instance IFS Files Locations• IBM i keeps Apache instance files under the /www folder• Typically the instance name matches the job name when running• ZENDPHP7 is for Zend Server 9. ZENDSVR6 is for Zend Server 6,

7, or 8.• /conf holds the fastcgi.conf and httpd.conf files. httpd.conf can be

extended with include files in other folders. httpd.conf directives can be overridden in directories using .htaccess files.

• /htdocs is the default content folder, specified by the DocumentRoot directive. Content can be found in other directories, based on various directives, includes in scripts, and the include path defined in PHP.

• /logs is where the access and error logs are found. These are created new every day (with date stamp) by IBM Apache. FastCGI errors and the FastCGI socket also reside here.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

65

Apache Instance IFS Files Locations

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

66

Zend Server Components

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

67

Zend Server ComponentsIFS PASE IBM i The

NetTCP/IP

(address)Apache (port)

FastCGI(handler)

PHP Parent

Zend Server Components

PHP Child (many)

Ibm_db2Toolkitmysqli

MonitorJob Queue

Deploymentprngd

Java Bridge

Content

DB2

Jobs, Library Objects

PHPhtmlcssjs

pdfxlsetc

ConfigsApacheFastCGI

PHP

DataMariaDB

MariaDBServer

http requesthttp response

*PGM*CMDSPLF

*DTAARALogs,

Sessions, etc.

You are here

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

68

Zend Server Components

• Zend Server components are not part of PHP. You do not have to run them to run PHP.

• Zend Server does include many PHP APIs that interact with these components. Obviously, those API methods won’t work if the components are not active.

• Components run as PASE processes in batch jobs. Typically components run in two jobs. One job runs the watchdog program, which is a kind of controller. The other job runs the executable binary.

• Zend Server component jobs run in subsystem ZENDPHP7 (or ZENDSVR6 for versions 6-8).

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

69

Zend Server Components in ZENDPHP7 sbs

Job name Component What it is forZS_STR_PRN prngd Pseudo Random Number

Generator for SSL (optional)ZSDAEMON Server Daemon Manage UI operations (default)ZSDEPLMNG Deployment Manage applications, hosts,

libraries (default)ZSJAVA_BRG Java Bridge Use Java objects in PHP scripts

(optional)ZSJOBQMNG Job Queue Schedule PHP scripts to run

(default)ZSMONMNG Monitor Record and display Events

(default)

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

70

Zend Server Components in ZENDPHP7 sbs

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

71

Zend Server Components in Zend Server UI

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

72

Zend Server Components set a directive

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

73

Zend Server Components restart needed

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

74

Zend Server Components restart neededAfter saving the change, the directive enters a pending status and the value(s) pending change are highlighted in green.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

75

Restart Zend Server• To restart, click the restart icon, found in the upper right corner.

It is orange when a restart is due.• The restart will take your web site down for a couple of minutes,

so plan accordingly.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

76

Component change has taken effect

• After the restart, the changed directive value is now in effect.• The component is no longer in pending status, and the value is

no longer highlighted in green.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

77

PASE component configs in ../etc

• For components that use daemons or other parts that run in the OS (PASE), configs can be found in /usr/local/zendphp7/etc

• This includes the main config file for PHP, which is php.ini• Never change configs in the config files! Always use the UI. This

prevents conflicts with the configurations stored in the database. It also helps prevent invalid values.

• Exception 1 – the UI will not start until the configuration is changed. This is very rare.

• Exception 2 – the directive is not available in the UI. This is also very rare.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

78

Daemon component configs in ../etc

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

79

PHP Component configs in ../etc/conf.d

• For things that run in PHP, the configs are in conf.d.• This includes components, and also PHP extensions.• Never change configs in the config files! Always use the UI. This

prevents conflicts with the configurations stored in the database. It also helps prevent invalid values.

• Exception 1 – the UI will not start until the configuration is changed. This is very rare.

• Exception 2 – the directive is not available in the UI. This is also very rare.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

80

Finding our changed directive for OPcache

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

81

Viewing the directive in the .ini file

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

82

Did I mention?

• It bears repeating:• Never change configs in the config files! Always use the UI. This

prevents conflicts with the configurations stored in the database. It also helps prevent invalid values.

• Exception 1 – the UI will not start until the configuration is changed. This is very rare.

• Exception 2 – the directive is not available in the UI. This is also very rare.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

83

PHP and PHP Extensions

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

84

PHP on IBMi, illustratedIFS PASE IBM i The

NetTCP/IP

(address)Apache (port)

FastCGI(handler)

PHP Parent

Zend Server Components

PHP Child (many)

Ibm_db2Toolkitmysqli

MonitorJob Queue

Deploymentprngd

Java Bridge

Content

DB2

Jobs, Library Objects

PHPhtmlcssjs

pdfxlsetc

ConfigsApacheFastCGI

PHP

DataMariaDB

MariaDBServer

http requesthttp response

*PGM*CMDSPLF

*DTAARALogs,

Sessions, etc.

You are here

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

85

phpinfo() displays versions, directives, more

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

86

phpinfo() core (php.ini) directives

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

87

phpinfo() extensions - mysqli example

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

88

Configure PHP directives

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

89

Core directives are grouped into categories

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

90

max_execution_time is in the RL&T category

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

91

max_execution_time search

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

92

max_execution_time search result

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

93

Changing directives is all the same

• Changing directives for PHP works pretty much the same as changing directives for components. So, we won’t go through it all again. Please review the Components section for this procedure.

• You can change more than one directive per restart. Change and save as many as you need. Restart once.

• Keep track of your configuration changes. You may need to reinstall some day.

• Make your config changes in the UI.• A common mistake is to attempt to set an extension directive in

php.ini. Internet examples often show this. Extension directives need to be changed in the .ini file for that extension, in the conf.d directory. Using the UI insures the change is made in the correct file.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

94

.ini files go in ../etc and../etc/conf.d• As we discovered when discussing components, configs for things

that run directly in PASE, like php.ini, can be found in /usr/local/zendphp7/etc, and configs for extensions and components that run under PHP are found in /usr/local/zendphp7/etc/conf.d.

• conf.d is defined in php.ini:[Zend]zend.install_dir=/usr/local/zendphp7zend.conf_dir=/usr/local/zendphp7/etczend.ini_scandir=conf.d

• Graphic slides showing these directories can be found in the Components section, above.

• Please don’t edit files in these directories. Instead, use the UI to make changes to the directives.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

95

Logs

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

96

PHP and Zend Server Component logs• The PHP log and the logs for Zend Server components are kept in

directory /usr/local/zendphp7/var/log• They are also viewable in the Zend Server UI. In the UI, you

display the last however many lines you specify (up to 10000, 200 by default) of a selected log. You may choose to auto refresh the log every however many seconds (up to 600) you specify, and you can search the log for a string.

• The log directory is the first thing I look at when you send me a Support Tool output file. A bloated log directory is the most likely reason your Support Tool is to large to send.

• You should rotate your php.log file once in a while:https://support.zend.com/hc/en-us/articles/203765456

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

97

Looking at logs in the UI

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

98

Looking at logs in the UI - continued

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

99

Clearing out detached logs

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

100

Content

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

101

Content can be anywhere• Content is any file that Apache or PHP can go and get and return to the

requester.• The Apache DocumentRoot directive sets the default content folder. This can

be set for the entire server, and then set different DocumentRoot directives for virtual hosts.

• Apache can also use directives like Alias or the mod_rewrite directives to further modify where it will find content.

• PHP can go further, plucking files from an include_path or just directly by the full path name. PHP can also grab data from your data bases, and content from servers on the internet.

• The IFS even makes it possible to access files stored as objects in libraries using the /QSYS.LIB directory.

• So really, your content can be anywhere. It is one of the tasks of the developer to know where things are supposed to be, and make sure they are where they ought to be.

• But don’t be overwhelmed. It is very simple to get started.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

102

Content – a simple start• The default DocumentRoot for the ZENDPHP7 instance is:

/www/zendphp7/htdocs• Use your editor to make a file /www/zendphp7/htdocs/hello.php.

Type this into your hello.php file:<?php echo "Hello World!“?>

• Save your file.• Go to your browser and type in this address:

http://<your IBM i IP address>:10090/hello.php• Hello World! should appear in your browser.

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

103

Content – a simple start

© 2016 Rogue Wave Software, Inc. All Rights Reserved.

104

ZendCon 2016 linkhttps://legacy.joind.in/19478

Recommended