Last Update: 12/08/2004
As I said before this page has been updated to reflect the modification which are required
to compile successfully PHP on the iSeries with the GNU GCC
compiler. I went probably trough the same burden as Rob Ward. So, I hope that will help
somebody else. The original document of IBM which help Rob and I a lot, can be found here :
PHP to Your IBM eserver iSeries Server"
- OS/400 V5R2 or
- OS/400 PASE environment
(5722-SS1 Option 33)
- System Openness
Includes (5722-SS1 Option 13)
- HTTP Server for
- Latest CUME and
Group PTFs for above products
IBM suggest a PRPQ which is 5799-PTL. The status for now of this PRPQ is "trial and betas",
so you can download it for free right now. This package contains iSeries Tools for Developers,
which contains Perl 5.005_03 along with other tools. For a full list of utilities in the Tools package
Perl is required
to compile many open source software. However, you do not need this
PRPQ if all you want is Perl. Binaries for iSeries PASE are available
at the Comprehensive Perl Archive Network http://www.cpan.org
Perl for iSeries
- Download the Perl
5.8.0 iSeries PASE binaries from CPAN website at http://www.cpan.org/ports/os400/
the zipped tarball. (I used Winzip for Windows)
- Create the folder perlpkg in
the QOpenSys file system and copy the uncompressed tarball
to the new folder. (I used iSeries Navigator to create the
folder and copy the uncompressed tarball)
- Start a PASE terminal
session by entering CALL QP2TERM in your 5250 terminal session
For easier access
to the Perl utilities I created symbolic links to the /usr/bin folder
command: cd /QOpenSys/perlpkg
command: tar -xvf email@example.com (this
will install Perl in /QOpenSys/perl)
To make sure Perl
installed correctly enter command: perl -v
command: ln -fs /QOpenSys/perl/bin/* /QOpenSys/usr/bin
This will create symbolic links to the Perl binaries in the /QOpenSys/usr/bin folder
which is part of the standard PATH environment variable.
you want to see what your PATH environment variable contains
enter the command: env PATH
The command should return:
This is perl, v5.8.0 built for aix
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2002, Larry Wall
Install the GNU GCC compiler for AIX
- Download the free gcc binary that you can find here
I chose to use the AIX 5.1 version because that was supported by my test machine
which run with OS/400 version 5.2. In fact the PASE environment of OS/400 5.2
is built with the AIX runtime 4.3, 5.1 and 5.2. I also chose the latest version of
gcc available on the above website which is 3.3.4.
- As it is a binary archive, you must upload it
to the QOpenSys directory. After that, you can uncompress it with the
uncompress command :
That will give you a tar file. You can then untar it with the
following command :
- Enter command: uncompress gcc.xxxx.tar.Z
- Enter command: tar -xvf gcc.xxxx.tar
This is important to do this in the QOpenSys directory, because when you
will untar the archive that will create a directory tree which start by usr, and there is a pre-built
directory called "usr" in the QOpenSys directory. It is also important to put it there because this file
system support long names. and you can have long names with open-source software. It is also important
to know that the "local" subdirectory of /QOpenSys/usr don't exist if you do a fresh install.
The fact that you untar gcc will create it. You must also know that most of the open-source
software need to use the /usr/local directory that's why we nedd to do the following step.
Create a symbolic link bettween /usr/local and /QOpenSys/usr/local. To do that you must enter
the following commands :
- Enter command: cd /usr
- Enter command: ln -s /QOpenSys/usr/local local
Now, I advise you to create a file called .profile
in your home directory where you can add the following line.
- export PATH=$PATH:/usr/local/bin
This will allow you to have the gcc compiler ready to use. If not, you will have
to type in time you want to use the gcc compiler his full path. You can also type
the above command in a QPTERM session.
a PASE terminal session by entering CALL QP2TERM in your 5250 terminal
session (if one is not already open)
You can check that gcc is working fine by typing gcc -v. If erverything is fine that should return
you some information about gcc and among them the gcc version.
Installing / Compiling PHP 4.3.x or PHP 5.0.x
You will have in some cases to interpret the instructions,
so they will fit your environment. In general you will
be following the instructions in the Redpaper with the exceptions below:
- Download the
source for PHP v4.3.x or PHP 5.0.x from
PHP 4.3.0 had a serious security flaw in it which 4.3.1 fixes. The
fix to the flaw is the only difference between 4.3.0 and 4.3.1)
- Create the folder phppkg in the QOpenSys
file system and copy the php-x.x.x.tar.gz file to it.
- Issue CD command to change directories to phppkg
(cd /QOpenSys/phppkg )
the php-x.x.x.tar.gz file by issuing command:
gzip -dc php-x.x.x.tar.gz | tar xvf -.
Be careful, don't forget the dash at the end of the command
- Since PHP needs to be patched to recognize DB2/400
you will need to download the patched file that I provide
here. Be careful, there is two version one for the PHP 4.3.x series
and another one for the PHP 5.0.x series. There is 2 sources files in there (php_odbc.c and php_odbc_include.h). So, of course,
you can checked the source. They have been modified according to the patch of IBM
that you can find here.
You can now replace the existing files that you can find in this directory :
By the way, Rob Ward provide the same patched file.
Remarks : if you want to install or to compile PHP v5.0.2, there is a required pre-requisite :
libxml2 must be installed. Personnaly, I used the version 2.6.15 that you can find
You can upload this archive in /QOpenSys/usr/local and uncompress it with gzip -dc libxml2-2.6.15.tar.gz | tar xvf -
(don't forget the dash at the end). When the archive is decompressed you will find a directory
called libxml2-2.6.15. Just do a "cd" into it. Then you can use the following configure command :
./configure --enable-ipv6=no --build=powerpc-ibm-aix188.8.131.52 --host=powerpc-ibm-aix184.108.40.206
It is important to use the --enable-ipv6=no option. If you don't do that the compilation won't work.
This is a known problem with AIX (which is the PASE runtime). When the configuration step is over
you can use the following 2 commands :
The first step will compile everything, and the second one will install everything
in /usr/local (you must have created a symbolic link between /usr/local and
- If you are on
V5R1 and do not have the patch or make commands you can get the AIX binaries
from the UCLA Public Domain Software Library for AIX at: http://aixpdslib.seas.ucla.edu
- Copy sqlcli.h , as400_libc.exp, and libdb400.exp from /QIBM/include/* to
the phppkg folder
You will find as400_libc.exp and libdb400.exp in the /QOpenSys/QIBM/ProdData/OS400/PASE/lib directory. After the copy of these
files is done in the /QOpenSys/phppkg directory, make sure that you can read them with e.g. the DSPLNK command.
These 3 files are in clear text so they should be human readable. If you cannot read them this is because you used
the wrong parameter in the copy command. Another way to copy them is to do an ftp to the same machine the conversion
will be handle properly.
Enter command: CPY OBJ('/QIBM/include/sqlcli.h') TODIR('/QOpenSys/phppkg/') TOCCSID(*STDASCII) DTAFMT(*TEXT)
- Set the CFLAGS, CC, and LDFLAGS environment variables by entering
the 3 following commands. Make sure you change the
export command to reflect where you placed the iSeries specific files. Also
add -O2 to the CFLAGS export to allow the compiler
to perform optimization. My export parameters looked like this:
export CFLAGS="-O2 -mcpu=powerpc -Wa,-many -DPASE -I /QOpenSys/phppkg/php-x.x.x"
- **These new instructions replace the "edit the
makefile" instructions in the Redpaper
need to edit the configure file. Use the EDTF command
- EDTF "/QOpenSys/phppkg/php-4.3.x/configure"
for db2inst1 and change:
- Search for -ldb2 and change
- CD /QOpenSys/phppkg/php-x.x.x and run Configure
./configure --with-ibm-db2 --with-config-file-path=/QOpenSys/php/etc --prefix=/QOpenSys/php/ --enable-force-cgi-redirect --with-mysql --enable-inline-optimization --disable-debug --with-zlib --build=powerpc-ibm-aix220.127.116.11 --host=powerpc-ibm-aix18.104.22.168
Be careful to the above command beccause this is through it that you can configure
the PHP functions. So, most of the time the configuration process try to detect
that the required function are already installed. For example, if you want to
use the --with-mysql option, mysql must be installed previously. Of course, if you download
one of the binary distribution that you will find on this website, you won't have
this problem. However, in this case a call to the unknown function will crash PHP.
editing the makefile and the other files, do not use a Windows editor (such
as Wordpad). I used the OS/400 command EDTF.
Note: Bryan Logan has informed me that you can use a
Windows editor but you will need to modify the Makefile afterwords to strip
out the carriage returns with the following commands:
tr -d '\r' < Makefile > Makefile.new
mv Makefile.new Makefile
- If make complains it can't
find the Makefile, use the -f switch to identify the location of the Makefile.
For example: make -f /QOpenSys/phppkg/php-4.3.0/Makefile Also,
during the make process you will see some errors(ie.
Function argument assignement between types xxx and
yyy is not allowed) These
errors are not fatal and AFAIK does not affect the
- Edit the main/php_config.h file:
- Delete #define HAVE_MMAP 1
- Delete #define HAVE_SETITIMER 1
- Run the MAKE command:
- cp php.ini-dist /QOpenSys/php/etc/php.ini
- Once PHP is installed
and ready to go use the command: /QOpenSys/php/bin/php -v
This should display the version and confirm the install completed
Make sure you setup
the folder and file permissions properly in the /QOpenSys/php/bin
folder and on the php executable. The
IBM Apache server uses the user profile: QTMHHTP1 when calling CGI applications
unless you change the Server User Profile in the Apache config. Refer
to the documentation in
IBM iSeries Info Center.
or user QTMHHTP1 will need to have read access to the QOpenSys folder,
read access to the php folder, and read access to the bin folder.
They will also need read and execute access to the php executable in
the /QOpenSys/php/bin folder.
Make sure you have the latest PTFs for the PASE environment
and for the HTTP server (powered by Apache). Go to http://www-919.ibm.com/developer/factory/pase/misc.html for
info on the latest PASE ptfs.
The workaround for the PHP_SELF bug in
the Redpaper may not need to be applied for 4.3.1 or 4.3.3 on V5R2.
If you setup a simple test page like the sample below and run it you
should be able to find the _SERVER["PHP_SELF"] variable and
it's value should be the name of the page. (ie. /test.php)
< title>PHP Info Page</title>
and PHP cannot co-exist on the same web server instance without enforcing
client authentication where Net.Data apps run under one user profile
and PHP apps run under another user profile. For more detail
on this, visit the Net.Data forum: