Advertisement
Advertisement

More Related Content

Advertisement

PHP Installed on IBM i - the Nickel Tour

  1. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 1 PHP installed on IBM i The Nickel Tour Rod Flohr, IBM i Support Specialist ZendCon 2016 link https://legacy.joind.in/19478
  2. © 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:
  3. © 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.
  4. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 4 PHP on IBMi, illustrated IFS PASE IBM i The Net TCP/IP (address) Apache (port) FastCGI (handler) PHP Parent Zend Server Components PHP Child (many) Ibm_db2 Toolkit mysqli Monitor Job Queue Deployment prngd Java Bridge Content DB2 Jobs, Library Objects PHP html css js pdf xls etc Configs Apache FastCGI PHP Data MariaDB MariaDB Server *PGM *CMD SPLF *DTAARA Logs, Sessions, etc.
  5. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 5 Installing Zend Server
  6. © 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
  7. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 7 Download from this page
  8. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 8 Unzip the downloaded file
  9. © 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')
  10. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 10 CRTSAVF command
  11. © 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
  12. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 12 Use netstat *cnn to verify FTP
  13. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 13 Netstat unsorted display
  14. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 14 Use F13 to sort the display
  15. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 15 Netstat sorted by local port
  16. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 16 Netstat after F14 to show port numbers
  17. © 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.
  18. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 18 Copy the current directory
  19. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 19 Type cd, a space, then paste
  20. © 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 address d. 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
  21. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 21 FTP the SAVF – FTP session
  22. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 22 DSPSAVF to make sure it is a valid SAVF
  23. © 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
  24. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 24 Verify prerequisites
  25. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 25 Verify prerequisites – go licpgm – option 10
  26. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 26 Verify prerequisites – 5733SC1 release check
  27. © 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)
  28. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 28 Optional CHGJOB step
  29. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 29 RSTLICPGM to install Zend Server 9
  30. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 30 RSTLICPGM – Welcome!
  31. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 31 RSTLICPGM – EULA – Please read
  32. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 32 RSTLICPGM progress messages
  33. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 33 RSTLICPGM – Success!
  34. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 34 Verify Success – go licpgm – option 10
  35. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 35 go zendphp7/zsmenu
  36. © 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.
  37. © 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.
  38. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 38 First UI access – License Agreement
  39. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 39 First UI access – Profile always Production!
  40. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 40 First UI access – Set admin password
  41. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 41 First UI access – Deploy Libraries
  42. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 42 First UI access – Summary – All done!
  43. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 43 Zend Server UI – Welcome!
  44. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 44 TCP/IP and Apache
  45. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 45 TCP/IP and Apache IFS PASE IBM i The Net TCP/IP (address) Apache (port) FastCGI (handler) PHP Parent Zend Server Components PHP Child (many) Ibm_db2 Toolkit mysqli Monitor Job Queue Deployment prngd Java Bridge Content DB2 Jobs, Library Objects PHP html css js pdf xls etc Configs Apache FastCGI PHP Data MariaDB MariaDB Server *PGM *CMD SPLF *DTAARA Logs, Sessions, etc. You are here And here
  46. © 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.com zend.com • You can ping a domain to discover its IP address (provided it will respond to pings).
  47. © 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.
  48. © 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 80 https 443 ftp 21 ssh 22 telnet 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
  49. © 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.
  50. © 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 – ZENDPHP7 Version 6, 7, and 8 – ZENDSVR6 Version 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
  51. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 51 Apache config file httpd.conf
  52. © 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!
  53. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 53 Enable all file editing in Navigator
  54. © 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 applications 10091 – Zend Server User Interface 10093 – User Server (internal use by Zend Server components) • ZENDSVR6 (Zend Server 6, 7, 8) ports: 10080 – Default port for applications 10081 – Zend Server User Interface 10083 – User Server (internal use by Zend Server components) • Defined in the httpd.conf file
  55. © 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 *:10091 NameVirtualHost *:10091 Listen *:10090 NameVirtualHost *:10090 • The Listen directive for port 10093 is found by the Virtual Host definition for the User Server: Listen 127.0.0.1:10093 NameVirtualHost 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.
  56. © 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?
  57. © 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 fastcgi AddType application/x-httpd-php .php AddHandler fastcgi-script .php • The AddHandler directive sets the handler for the given extension, which is .php .
  58. © 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
  59. © 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.
  60. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 60 PHP Child Process, Resting
  61. © 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 for PGM-QZHBMAIN SIGW Mainline PGM-QZSRLOG SIGW Logs (Two of these, access and error) PGM-QZSRHTTP SIGW Apache (HTTP Server) PGM-zfcgi SELW FastCGI PGM-php-cgi.bi THDW PHP Parent (one of these, by default) PGM-php-cgi.bi TIMW TIMA Others PHP Child (many of these, 10 by default) This is where the PHP scripts run.
  62. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 62 wrkactjob sbs(qhttpsvr)
  63. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 63 IBM Web Administration for i • http://<your IP address>:2001/HTTPAdmin/
  64. © 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.
  65. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 65 Apache Instance IFS Files Locations
  66. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 66 Zend Server Components
  67. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 67 Zend Server Components IFS PASE IBM i The Net TCP/IP (address) Apache (port) FastCGI (handler) PHP Parent Zend Server Components PHP Child (many) Ibm_db2 Toolkit mysqli Monitor Job Queue Deployment prngd Java Bridge Content DB2 Jobs, Library Objects PHP html css js pdf xls etc Configs Apache FastCGI PHP Data MariaDB MariaDB Server *PGM *CMD SPLF *DTAARA Logs, Sessions, etc. You are here
  68. © 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).
  69. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 69 Zend Server Components in ZENDPHP7 sbs Job name Component What it is for ZS_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)
  70. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 70 Zend Server Components in ZENDPHP7 sbs
  71. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 71 Zend Server Components in Zend Server UI
  72. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 72 Zend Server Components set a directive
  73. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 73 Zend Server Components restart needed
  74. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 74 Zend Server Components restart needed After saving the change, the directive enters a pending status and the value(s) pending change are highlighted in green.
  75. © 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.
  76. © 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.
  77. © 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.
  78. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 78 Daemon component configs in ../etc
  79. © 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.
  80. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 80 Finding our changed directive for OPcache
  81. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 81 Viewing the directive in the .ini file
  82. © 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.
  83. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 83 PHP and PHP Extensions
  84. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 84 PHP on IBMi, illustrated IFS PASE IBM i The Net TCP/IP (address) Apache (port) FastCGI (handler) PHP Parent Zend Server Components PHP Child (many) Ibm_db2 Toolkit mysqli Monitor Job Queue Deployment prngd Java Bridge Content DB2 Jobs, Library Objects PHP html css js pdf xls etc Configs Apache FastCGI PHP Data MariaDB MariaDB Server *PGM *CMD SPLF *DTAARA Logs, Sessions, etc. You are here
  85. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 85 phpinfo() displays versions, directives, more
  86. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 86 phpinfo() core (php.ini) directives
  87. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 87 phpinfo() extensions - mysqli example
  88. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 88 Configure PHP directives
  89. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 89 Core directives are grouped into categories
  90. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 90 max_execution_time is in the RL&T category
  91. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 91 max_execution_time search
  92. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 92 max_execution_time search result
  93. © 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.
  94. © 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/zendphp7 zend.conf_dir=/usr/local/zendphp7/etc zend.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.
  95. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 95 Logs
  96. © 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
  97. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 97 Looking at logs in the UI
  98. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 98 Looking at logs in the UI - continued
  99. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 99 Clearing out detached logs
  100. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 100 Content
  101. © 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.
  102. © 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.
  103. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 103 Content – a simple start
  104. © 2016 Rogue Wave Software, Inc. All Rights Reserved. 104 ZendCon 2016 link https://legacy.joind.in/19478

Editor's Notes

  1. I borrowed this title from wirecutter.com, an electronics review site I really like.
  2. It’s like showing the new guy around the office. It’s probably enough to know where the supply cabinet is. You don’t have to stop and take inventory. Ooooh! Mechanical pencils. Pentel! I like those!
  3. And also, I want to show you all this in 50 minutes. It’s kind of a lot. Incidentally, that is an actual picture of the Internet. That is exactly how it looks.
  4. KB article: Download and install Zend Server for IBM i
  5. Always make sure to select IBM i as the platform. This field has a tendency to flip back to Windows.
  6. You will have a folder containing installation instructions and a save file. Always use the included instructions, rather than the instructions in the online documentation. The included instructions should be specific to this install.
  7. These instructions are verbatim from the installation instructions included in the download. If you FTP the file before creating it as a Save File, it will be created automatically as a Physical File.
  8. Continuing with the included instructions. This is a good excuse to give a quick demo of how to use netstat in a certain way that can be very useful from time to time.
  9. Yes, we can already see that FTP is running, but let’s move on with the demo anyway.
  10. F13 brings up the sort window. Select Local Port with a one.
  11. Use F14 to show port numbers.
  12. And there is FTP port 21.
  13. Right clicking the directory collapses it into a more DOS friendly format for copy/paste. Copy it.
  14. This is a handy, if somewhat clunky, feature to use copy and paste in the Command Prompt. Click the C:/ icon to access the context menu.
  15. Don’t miss the bin command!
  16. Enter the FTP command, then your name and password when prompted. Don’t forget the “bin” command! You can copy and past the put command in from the instructions.
  17. This is just a quick sanity check to make sure the file is not a physical. Could happen if we misspelled the save file name when creating it, or when doing the PUT from FTP. dspsavf qgpl/zendphp7
  18. 5733SC1 is the most likely to be missing. 5733SC1 also must be at the same level as the OS!
  19. Use F11 to display the release of 5733SC1. It must be the same release as the OS!
  20. Use F11 to display the release of 5733SC1. It must be the same release as the OS!
  21. I like to do the interactive installation. Makes it easier to spot an issue in the install. I also like to set log level to LOG(4 00 *SECLVL) LOGCLPGM(*YES) although, I did see one installation fail because it wrapped the job log, due to settings on the customer machine.
  22. This is just something I like to do, being a Support guy.
  23. This tells some basic info about what is installed. Briefly mention each item.
  24. Press enter to accept. By all means read this. Not near as long as the EULA on your smart phone…
  25. Occasional progress messages will appear.
  26. That’s it. It is installed. Let’s check a couple of things, and then set up the UI.
  27. Licensed program has a normal *INSTALLED status. Also, notice we still have Zend Server 8.5.2 installed on this same machine.
  28. go zendphp7/zsmenu to see that the menu is there, another quick sanity check. You can also look at the jobs shown by Option 3 to make sure they are all there. We have a KB article that tells what they all need to be.
  29. This should be done after installation, to accomplish the set up steps.
  30. Read that EULA one more time!
  31. Production is best for a single server. IBM i is always a single server.
  32. Admin can update. Developer can only read.
  33. This actually goes pretty fast.
  34. All done! That wasn’t so bad.
  35. After finishing the one time setup, this is the default start page.
  36. This section is really the “Nickel Tour” I give customers, or most of it. This is the part I really want to get across to an RPG programmer with no web experience. By the way, this is derived from a flow chart that has been floating around here in various formats forever. I did flip it around and add some stuff for the purpose of this presentation, which is to show where things are. Also, my version is just a bunch of text in boxes with arrows that all go both ways. Well, except for that one picture of the actual internet.
  37. Ping is a command you can run in Windows and on the IBM i command line.
  38. I don’t know anybody’s phone number anymore. I used to have a lot of numbers memorized. Now I just look them up on my phone. I don’t even know my wife’s number. Like a company with more than one phone number, a computer can have more than one IP address. Each IP address has it’s own ports, so the same port number can be used twice, if the IP is different.
  39. Request parameters are usually GET or POST parameters. GET parameters appear in the URL, so they are handy for bookmarking pages.
  40. We get a lot of questions about why Zend Server 7 or 8 use the zendsvr6 folder and library name. They are all the same licensed program.
  41. Never edit a binary file! Actually, never edit any file unless you know exactly what you are doing, and why.
  42. With great power comes great responsibility… There is a reason the edit option is disabled by default for most file types.
  43. All three ports have to be reserved for the Zend Server instance. If any of them is in use at start up, the start up will fail. This is why netstat can be so handy sometimes.
  44. The NameVirtualHost directive doesn’t really do anything anymore in Apache 2.4. We keep it for now to provide 7.1 (Apache 2.2) compatibility.
  45. PHP constructs a web page from static elements, data bases, information it finds on the web, and so on. It makes a Dynamic web page. By the way, question marks are the official flow chart symbol for “how does it know to do that?”.
  46. The AddHandler directive pulls it all together to make sure .php scripts are processed by PHP. Notes on CGI: Common Gateway Interface – CGI is a way for web servers like Apache to talk to server programs like PHP. FastCGI is an open source CGI, compiled by OBM and included as part of the IBM HTTP Server Licensed Program distribution. They called it zend_enabler_module because they put it in when PHP was the only language in town, but it is now being used for other languages as well. It causes some confusion as to who supports it, since “zend” is in the name of it.
  47. Notice Server type matches the AddType directive on the previous slide. CommandLine shows the location of the PHP executable. Go through the rest of the environment variables. PHPRC is the path to php,ini. It can be a problem if an editor wraps the line for display, and then leaves it like that with the line feeds inserted when it saves.
  48. Sometimes the most important piece of information we have when researching an issue for support is the output found in that QPRINT spool file. It is often overlooked, because many people are just not aware of this method of writing shell output.
  49. When you see “QP0C”, you’re not in Kansas anymore… The QP2 prefix is associated with the PASE shell. Php-cgi.bin is running fcgi_accept_request, so it looks like it is ready to accept the next request that comes.
  50. It is important for all of these to be active when Apache is up, and for all of them to be stopped when Apache is stopped. If any of these are left over in an active state after Apache is stopped (zombie jobs), the same Apache instance cannot start back up.
  51. There are actually 10 of the php-cgi jobs in TIMW status, the default number as configured in our distribution.
  52. This screen shot shows the web address for the IBM Apache Admin. We navigated over to the ZENDPHP7 instance using the tabs and selection boxes in the UI. By the way, notice that the Apache version number appears here. The menu to the left shows the many things you can do in here.
  53. See next slide for a screen shot of Navigator.
  54. Here we have Zend Server 9 and Zend Server 8 with the standard Apache folder structure for IBM i. Apachedft and iwadft are IBM configs.
  55. This is what it looks like with all of them running. Usually ZS_STR_PRN is not there by default, and ZSJAVA_BRG comes and goes, even if it is not in use.
  56. If you double click, the directives expand and collapse, sometimes so quick you won’t notice. So be sure to only click once. The screen is so small in this screen shot you can’t see the tab we are on. It is Administration -> Components
  57. Changes to directives should always be done in the UI. This prevents the UI database from falling out of sync with the actual configuration files. If they are out of sync, notifications will appear. Directive names are usually in the format of component.directive, to specify what the directive applies to.
  58. The green changes saved message only stays around for a moment. The restart is required message sticks around much longer.
  59. Another way you can tell you need a restart is the status is pending, and the value is green.
  60. Still another way to tell a restart is due is that the restart icon is orange. After clicking the icon, you will be given the opportunity to cancel the restart.
  61. Your new directive value is now the law of the land.
  62. Config files are text files with the .ini suffix. Typical line format is directive=value. If a directive is not in the UI, there is likely to be some good reason why it is not advisable to change it.
  63. I know you see examples on the internet where they change this or that config file. If all your friends jumped off a bridge… You can probably make the same change using the UI, so please do it that way.
  64. Remember how we enabled editing in Navigator? Remember how I told you to be careful not to change things? The editor should only be used to display files contents most of the time. This is one of those times. Just because it says “Edit” doesn’t mean you actually have to change something.
  65. Note each directive is commented. The comment starts with a semicolon. Again, directives take the format component.directive.
  66. Why do I keep repeating this? 10 years of support experience. Also, people read slide decks out of order, and this is one thing I really want to get across.
  67. Let’s start back in the UI, with the PHP Info display. You can actually run the phpinfo() function in a script to display much of the same information, although in a less pretty presentation. Notice the Version info at the top, and the config file locations.
  68. Local value is the runtime value for a directive. Master value is the value in the .ini file. Notice no prefix for the core directives.
  69. Scroll down some more to see more extensions. Here is mysqli. Includes general information about the extension as well as directives. Notice the prefix for the extension.
  70. This tab allows for editing of all the PHP directives, not just extensions. See next slide.
  71. Notice the blank status for categories. These categories happen to be pretty close together in the table, which is why I chose them for the screen shot. Most of them are not so close together.
  72. We can find max_execution_time under the Resource Limits and Tuning category. But we don’t have to know the category to find it.
  73. We can simply search for the directive we want.
  74. Easy peasy.
  75. It is better to have a process around configuration changes to capture them. In the event you need to do a clean install, you will want to be able to put things back the way you like them. In general it is not a good idea to just poke around and change this or that to see what it might do. It is better to make deliberate choices and carefully observe the effects. Oh, and here’s another reason why it is a good idea to make your changes in the UI.
  76. I keep mentioning not to edit these files because people do not always read slide decks in sequential order, and it is important.
  77. Digging through logs is not so much fun, but sometimes it just has to be done.
  78. Navigate to Monitoring -> Logs. Select the log you want to view. You can search for a string. Type in the string and press enter. More on next slide.
  79. Not sure under what dire circumstance I would find a use for auto refreshing one of these logs every 30 seconds, but I am sure there must be something.
  80. Zend Server logs detach at a certain specified size, 10m by default. When detached, they are renamed with a time stamp. Old logs do not need to be retained for a long time. They can usually be safely removed, or moved to another folder for archive purposes. Leaving too many here can cause the Support Tool to be too large to send. Remember you can also remove old php logs if you are rotating them regularly.
  81. I don’t really have a good definition of “content” in this context. I am just going by usage.
  82. Is that code? There wasn’t supposed to be any code in this presentation. Maybe it doesn’t count, since this program doesn’t do much of anything but confirm its own existence.
  83. That’s all for now!
Advertisement