IASP

Who is this page for?

Instructions designed for IBM i developer learning PHP …

The following iASP configuration worked just fine using a V6R1 machine with latest Zend Server 5.1.1.

I left Zend Server “product base” in root system ASP /usr/local/zendsvr and library ZENDSVR (where it installs), but moved “my data” configuration/demos/scripts from /www/zendsvr to /myasp2/www/zend2.

I did not use symbolic links /www/zendsvr → /myasp2/www/zend2 even though it may work, a clean break between SYSASP and iASP content seems more in keeping with “independent” HA. This example Apache starts/stops clean independent configuration, while Zend Server product updates/PTFs stay away from my iASP data.

I am not sure you can move Zend Server “product base” into iASP(s), but from my point of view all HA user interesting Zend Server bits moved into an iASP with very few steps and it seems to run fine (read RSTLICPGM Zend Server bottom page).

Summary of my machine iASP

SYSASP -- ZENDSVR library ... everything as installed
SYSASP -- /usr/local/zendsvr ... everything as installed
SYSASP -- /tmp ... many Zend "enterprise" components use /tmp
MYASP2 -- /myasp2/www/zend2 ... ALL "user data" moved from /www/zendsvr (/conf, /logs, /htdocs)
More ... /myasp2/www/zend2
-- NO symbolic links between SYSAPS and MYASP2 for true "independent" ASP.
-- config files /myasp2/www/zend2/conf

>cd /MYASP2/www/zend2/conf
>ls
fastcgi.conf     <--- PHP "children"
httpd.conf       <--- Apache ZEND2 "instance"

> cat fastcgi.conf
; Static PHP servers for default user (one line with NO line feeds)
Server type="application/x-httpd-php" CommandLine="/usr/local/ZendSvr/bin/php-cgi.bin" StartProcesses="1" SetEnv="LIBPATH=/usr/local/ZendSvr/lib" SetEnv="PHPRC=/usr/local/ZendSvr/etc/" SetEnv="PHP_FCGI_CHILDREN=10" SetEnv="PHP_FCGI_MAX_REQUESTS=0" ConnectionTimeout="30" RequestTimeout="60" SetEnv="CCSID=819" SetEnv="LANG=C" SetEnv="INSTALLATION_UID=20111108100706281116" SetEnv="LDR_CNTRL=MAXDATA=0x40000000"
; Where to place socket files
IpcDir /myasp2/www/zend2/logs
IpcPublic *RWX

Where:
StartProcesses="1"            <--- start 1 php-cgi "mother" to watch over children
SetEnv="PHP_FCGI_CHILDREN=10" <--- "mother" start 10 php-cgi children to handle FastCGI any.php work (run php script)
                                   if a php-cgi child dies, "mother" php-cgi will replace with a new child
SetEnv="LDR_CNTRL=MAXDATA=0x40000000" <--- bigger PASE program 4*256MB heap to run (optional) 
IpcDir /myasp2/www/zend2/logs <--- Unix domain socket where children monitor for any.php requests from Apache
> cd /myasp2/www/zend2/logs
> ls *.sock
fcgi-gicclkhb.sock            <--- Active set of php-cgi children ready to run (10 php-cgi children)  
fcgi-oecclkhb.sock            <--- "HotBackup On" php-cgi children ready to go on death of "mother"+10 php-cgi children (never happens)  


> cat httpd.conf
# Configuration originally created by Create HTTP Server wizard on Tue Apr 11 01:53:18 CDT 2006
LoadModule proxy_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_http_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_connect_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_ftp_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule zend_enabler_module /QSYS.LIB/QHTTPSVR.LIB/QZFAST.SRVPGM  <--- PASE FastCGI enabled (fastcgi.conf)
:
Listen *:80                           <--- IF multiple ZS instances you need a different port (default zend 10088)
DocumentRoot /myasp2/www/zend2/htdocs <--- IF multiple ZS instances you need a different DocumentRoot (default /www/zendsvr/htdocs)
:
HotBackup On                          <-- hot back up web site and PHP mother + PHP children
:
DefaultFsCCSID 37                     <-- need for CCSID 65535 machine (really good idea anyway)
CGIJobCCSID 37                        <-- need for CCSID 65535 machine (really good idea anyway)
:
AddType application/x-httpd-php .php  <-- handle any.php ...
AddHandler fastcgi-script .php        <-- any.php as FastCGI script (QZFAST.SRVPGM -> fastcgi.conf)
:
RewriteEngine on
:
<Directory /myasp2/www/zend2/htdocs>
  Options FollowSymLinks 
  order allow,deny
  allow from all
  AllowOverride all
</Directory>

Step 1) Apache instance /myasp2/www “trick”

Any IBM i Apache managed “instance” is stored following location QUSRSYS, so “trick” is simply to get startup command correct in “instance” member (ZEND2: -apache -d /myasp2/www/zend2 -f conf/httpd.conf). It is nice to technically know what is going on with IBM i Apache QATMHINSTC “instances”, BUT of course web GUI HTTPAdmin (2001 port) will handle Apache instances specifying new iASP root /myasp2 ( Server root: /myasp2/www/zend2 [Browse-button] ), and you can always “Browse-button” to find instance you moved into /myasp2/www/zend2 so you don’t have to go “hacking” this level of internal QATMHINSTC (IBM i web guys probably don’t want you to know where “instances” actually live … oops … but now you do).

When you move “user” configuration to /myasp2/www remember that you have to edit GUI HTTPAdmin configuration (/MYASP2/www/zend2/conf/httpd.conf) to specify new DocumentRoot /myasp2/www/zend2/htdocs + any hard coded <Directory, etc. … AND … don’t forget to move the FastCGI IPC socket location configuration (/MYASP2/www/zend2/conf/fastcgi.conf) IpcDir /myasp2/www/zend2/logs to avoid unwanted accidental duplicate FastCGI collision socket errors (keep all the “active” configuration bits in one iASP place). Last, take a look at my clean-up your system notes it may save you a bunch of hours frustration if you do it nice and clean.

=============
Apache "instances" my machine in iASP
=============
                          Work with Members Using PDM                 LP0264D

 File  . . . . . .   QATMHINSTC
   Library . . . .     QUSRSYS              Position to  . . . . .             

 Type options, press Enter.                                                   
   3=Copy    4=Delete         5=Display   7=Rename    8=Display description   
   9=Save    13=Change text   18=Change using DFU     25=Find string ...       

 Opt  Member      Date        Text                                             
      APACHEDFT   04/16/12                                                      
      IWADFT      04/16/12                                                      
      QIWIRELESS  04/16/12                                                      
      ZENDSVR     04/16/12                                                      
      ZEND2       04/16/12      

=============
active "Zend Server on my machine in iASP
=============
                          Display Physical File Member                         
 File . . . . . . :   QATMHINSTC          Library  . . . . :   QUSRSYS
 Member . . . . . :   ZEND2               Record . . . . . :   1
 Control  . . . . .                       Column . . . . . :   1
 Find . . . . . . .                                           
 *...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+...
 -apache -d /myasp2/www/zend2 -f conf/httpd.conf
                           ****** END OF DATA ******
=============
NOT active "Zend Server on my machine
=============

                          Display Physical File Member                         
 File . . . . . . :   QATMHINSTC          Library  . . . . :   QUSRSYS
 Member . . . . . :   ZENDSVR             Record . . . . . :   1
 Control  . . . . .                       Column . . . . . :   1
 Find . . . . . . .                                           
 *...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+...
 -apache -d /www/zendsvr  -f conf/httpd.conf
                           ****** END OF DATA ******

Step 2) Move /www/zendsvr to /myasp2/www/zend2

i have no problem running a “configured” Zend Server using an iASP …

  • Apache instance ZEND2 starts
  • PHP core runs fine (big wiki application, demos, etc.)
  • PHP DB2 to i - runs fine (ibm_db2, pdo_ibm, odbc, etc.)
  • PHP to XMLSERVICE IBM i - XMLSERVICE runs fine (call PGM, SRVPGM, CMD, etc.)
1) Apache root "as is" or "normal" sysasp
> cd /www
> pwd
/www
> ls -l 
total 80
drwxrwsr-x    5 nobody   0              8192 Oct 22 2007  apachedft --- not using this
drwxrwsr-x    5 qsys     0              8192 Oct 22 2007  iwadft
drwxrws---    5 qsecofr  0              8192 Nov  8 08:56 onmyasp2zendsvr -- not using this
drwxrws---    3 qsecofr  0              8192 Feb 20 10:01 zendsvrsav -- not using this

> 2) Zend Server instance artifacts in iASP
> cd /myasp2/www/
> pwd
/MYASP2/www
> ls -l
total 16
drwxrws---    5 qsecofr  0              8192 Nov  8 08:56 zend2 -- this is in iASP (using this one for Zend Server)
> cd zend2/
> ls -l
total 80
drwxrws---    2 qtmhhttp 0              8192 Apr  4 10:53 conf
drwxrws---    7 qtmhhttp 0              8192 Apr 12 10:43 htdocs
drwxrws---    2 qtmhhttp 0             24576 Apr 18 00:00 logs

3) my Zend Server fastcgi.conf
> cd /MYASP2/www/zend2/conf
> tail fastcgi.conf
; Static PHP servers for default user
Server type="application/x-httpd-php" CommandLine="/usr/local/ZendSvr/bin/php-cgi.bin" StartProcesses="1" SetEnv="LIBPATH=/usr/local/ZendSvr/lib" SetEnv="PHPRC=/usr/local/ZendSvr/etc/" SetEnv="PHP_FCGI_CHILDREN=10" SetEnv="PHP_FCGI_MAX_REQUESTS=0" ConnectionTimeout="30" RequestTimeout="60" SetEnv="CCSID=819" SetEnv="LANG=C" SetEnv="INSTALLATION_UID=20111108100706281116" SetEnv="LDR_CNTRL=MAXDATA=0x40000000"

; Where to place socket files
IpcDir /myasp2/www/zend2/logs <--- IF multiple ZS instances use different instance location (default /www/zendsvr/logs)

4) my Zend Server httpd.conf
> cd /MYASP2/www/zend2/conf
> grep -i myasp2 httpd.conf
DocumentRoot /myasp2/www/zend2/htdocs
<Directory /myasp2/www/zend2/htdocs>
<Directory "/myasp2/www/zend2/htdocs/Zend5250Emulator">
> grep -i listen httpd.conf
Listen *:80   <--- IF multiple ZS instances you need a different port (default zend 10088)

Step 0–3) Clean-up old junk during move

Just like when you move between homes, it is a REALLY good idea to throw out the old trash before moving to the iASP, here are my cleaning notes … ahhh … if you choose not to follow i cannot say if your new home in iASP will run (pack rats beware).

I. kill all old zend server /tmp artifacts before iASP move/restart 
endTCPSVR SERVER(*HTTP) HTTPSVR(ZENDSVR)
...wait ZENDSVR down completely ...
call qp2term 
> cd /tmp
> pwd
/tmp
> rm -R *
... rm -R * clears /tmp all Zend artifacts -- CAREFUL to be in /tmp or kill whole system (VERY VERY CAREFUL ... i mean it)


II. edit  /myasp2/www/zend2/conf/fastcgi.conf (be careful must be a ascii 819 file)
; Where to place socket files
IpcDir /myasp2/www/zend2/logs


III. edit /myasp2/www/zend2/conf/httpd.conf (use 2001 port gui to make sure ZEND2 instance is seen QATMHINSTC)
:
# save yourself a TON of CCSID trouble PHP/DB2/XMLSERVICE
DefaultFsCCSID 37   ... or 280 (Italian) ... or so on ...
CGIJobCCSID 37      ... or 280 (Italian) ... or so on ...
:
DocumentRoot /myasp2/www/zend2/htdocs
:
# Allow requests for files in document root
<Directory /myasp2/www/zend2/htdocs>
  Options FollowSymLinks 
  order allow,deny
  allow from all
  AllowOverride all
</Directory>
:
<Directory "/myasp2/www/zend2/htdocs/Zend5250Emulator">
Options FollowSymLinks
AllowOverride All
</Directory>
:
<Location /wiki>
  Order deny,allow
  Allow from all
</Location>
Alias /wiki "/myasp2/www/zend2/htdocs/wiki"

IV. restart ZEND2 Apache instance 
STRTCPSVR SERVER(*HTTP) HTTPSVR(ZEND2)

Optional - I wanted to start over by kill everything as i was doing a lot of machine “updating” test cw/xmlservice versions … state unknown … i recommend following actions assuming “my” system (be kind to others) …

1) end zendsrvr http 
ENDTCPSVR SERVER(*HTTP) INSTANCE(ZENDSVR)
... wrkactjob wait all php-cgi to go down, kill php-cgi *immed by hand if won't die ...

2) clear left over IPC attributes for cw/xmlservice test profiles ...
call qp2term
> ipcs | grep -i qtm | awk '{print "ipcrm -" tolower($1) " "$2}' | sh  
> ipcs | grep -i myid1 | awk '{print "ipcrm -" tolower($1) " "$2}' | sh  
> ipcs | grep -i myid2 | awk '{print "ipcrm -" tolower($1) " "$2}' | sh  
> ipcs | grep -i fred | awk '{print "ipcrm -" tolower($1) " "$2}' | sh  
> ipcs | grep -i barney | awk '{print "ipcrm -" tolower($1) " "$2}' | sh  
Where:
> qtm - clear IPCs for QTMHHTTP
> myid1 - clear IPCs for profile MYID1
> myid2 - clear IPCs for profile MYID2

3) carefully reset /tmp
call qp2term
> cd /tmp
> pwd
/tmp --- if you do not see /tmp, stop now rm -R may kill whole system
> rm -R *

4) recycle DB2 connections (optional) 
ENDPJ SBS(QSYSWRK) PGM(QSQSRVR) OPTION(*IMMED)
STRPJ SBS(QSYSWRK) PGM(QSQSRVR)

6) restart http
STRTCPSVR SERVER(*HTTP) HTTPSVR(ZEND2)

Next RSTLICPGM/PTF ZEND with /myasp2/www/zend2 (ZEND2)

Glass half full, glass half empty …

After you have your /myasp2/www/zend2 up and running (no problems), you may update “root” Zend Server product /www/zendsvr with less impact assuming you have not symbolic linked /www/zendsvr → /myasp2/www/zend2, a simple trick avoiding Apache/IFS name space collisions with default install Zend Server ZENDSVR (/www/zendsvr), for better control over “user specific configuration/data” iASP. Anyway, today’s RSTLIC would break symbolic linked /www/zendsvr → /myasp2/www/zend2 for a new hard link /www/zendsvr, so just seems easy to avoid the issue and only copy things wanted to /myasp2/www/zend2.

Commands

  • WRKCFGSTS CFGTYPE(*DEV) CFGD(*ASP)
  • DSPASPSTS ASPDEV(MYASP2)

Author(s)

Tony “Ranger” Cairns - IBM i PHP / PASE