Everyone knows installing PHP on IBM i is easy. Just download the save file and run the RSTLICPGM command. But not everyone knows what that RSTLICPGM does. What is it putting on the machine? Where is it putting it? How does it all work together? In this session, we'll take a look at the IFS directories added by the Zend Server installer, to see what's in them. We'll see where PHP and PHP extensions, Apache and FastCGI configurations, log files, and more are kept. We'll also talk about how these new file objects interact with existing prerequisite software on the IBM i to present dynamic pages to the web. This session is for PHP developers and administrators interested in learning how PHP fits in with the unique operating environment of IBM i.
I borrowed this title from wirecutter.com, an electronics review site I really like.
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!
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.
KB article: Download and install Zend Server for IBM i
Always make sure to select IBM i as the platform. This field has a tendency to flip back to Windows.
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.
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.
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.
Yes, we can already see that FTP is running, but let’s move on with the demo anyway.
F13 brings up the sort window. Select Local Port with a one.
Use F14 to show port numbers.
And there is FTP port 21.
Right clicking the directory collapses it into a more DOS friendly format for copy/paste. Copy it.
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.
Don’t miss the bin command!
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.
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
5733SC1 is the most likely to be missing. 5733SC1 also must be at the same level as the OS!
Use F11 to display the release of 5733SC1. It must be the same release as the OS!
Use F11 to display the release of 5733SC1. It must be the same release as the OS!
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.
This is just something I like to do, being a Support guy.
This tells some basic info about what is installed. Briefly mention each item.
Press enter to accept. By all means read this. Not near as long as the EULA on your smart phone…
Occasional progress messages will appear.
That’s it. It is installed. Let’s check a couple of things, and then set up the UI.
Licensed program has a normal *INSTALLED status. Also, notice we still have Zend Server 8.5.2 installed on this same machine.
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.
This should be done after installation, to accomplish the set up steps.
Read that EULA one more time!
Production is best for a single server. IBM i is always a single server.
Admin can update. Developer can only read.
This actually goes pretty fast.
All done! That wasn’t so bad.
After finishing the one time setup, this is the default start page.
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.
Ping is a command you can run in Windows and on the IBM i command line.
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.
Request parameters are usually GET or POST parameters. GET parameters appear in the URL, so they are handy for bookmarking pages.
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.
Never edit a binary file! Actually, never edit any file unless you know exactly what you are doing, and why.
With great power comes great responsibility… There is a reason the edit option is disabled by default for most file types.
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.
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.
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?”.
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.
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.
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.
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.
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.
There are actually 10 of the php-cgi jobs in TIMW status, the default number as configured in our distribution.
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.
See next slide for a screen shot of Navigator.
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.
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.
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
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.
The green changes saved message only stays around for a moment. The restart is required message sticks around much longer.
Another way you can tell you need a restart is the status is pending, and the value is green.
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.
Your new directive value is now the law of the land.
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.
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.
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.
Note each directive is commented. The comment starts with a semicolon. Again, directives take the format component.directive.
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.
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.
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.
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.
This tab allows for editing of all the PHP directives, not just extensions. See next slide.
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.
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.
We can simply search for the directive we want.
Easy peasy.
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.
I keep mentioning not to edit these files because people do not always read slide decks in sequential order, and it is important.
Digging through logs is not so much fun, but sometimes it just has to be done.
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.
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.
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.
I don’t really have a good definition of “content” in this context. I am just going by usage.
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.