Mikko Kortelainen

Installing PHP 5 on AIX using IBM HTTP Server

I was not able to compile PHP 5.2.6 with IBM HTTP Server 6.1 as a module, so I compiled it as a CGI binary instead. Here's how to do it.

1. Download the AIX toolbox from:

ftp://ftp.software.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc/

You don't need to download everything, but that is the easiest way. The whole toolbox is about 2.8 GB in size. If you have wget, just say:

wget ftp://ftp.software.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc/

2. Install GCC and the rest of the GNU toolchain

Go to the toolbox dir and run the following command.

xargs rpm -iv << EOF
autoconf/autoconf-2.59-1.aix5.1.noarch.rpm
automake/automake-1.8.5-1.aix5.1.noarch.rpm
binutils/binutils-2.14-3.aix5.1.ppc.rpm
gcc/gcc-4.2.0-3.aix5.3.ppc.rpm
gcc/gcc-cplusplus-4.2.0-3.aix5.3.ppc.rpm
gcc/gcc-locale-4.2.0-3.aix5.3.ppc.rpm
gcc/libgcc-4.2.0-3.aix5.3.ppc.rpm
gcc/libstdcplusplus-4.2.0-3.aix5.3.ppc.rpm
gcc/libstdcplusplus-devel-4.2.0-3.aix5.3.ppc.rpm
gdbm/gdbm-1.8.3-2.aix5.1.ppc.rpm
gdbm/gdbm-devel-1.8.3-2.aix5.1.ppc.rpm
libtool/libtool-1.5.8-2.aix5.1.ppc.rpm
m4/m4-1.4.1-1.aix5.1.ppc.rpm
make/make-3.80-1.aix5.1.ppc.rpm
EOF

You will probably want to replace the package names with the newest versions.

3. Install PHP 5 prerequisites

In the same toolbox dir, run:

xargs rpm -iv << EOF
bzip2/bzip2-1.0.2-4.aix5.1.ppc.rpm
gd/gd-1.8.4-3.aix5.1.ppc.rpm
gd/gd-devel-1.8.4-3.aix5.1.ppc.rpm
gd/gd-progs-1.8.4-3.aix5.1.ppc.rpm
gettext/gettext-0.10.40-8.aix5.2.ppc.rpm
libpng/libpng-1.2.8-8.aix5.2.ppc.rpm
libpng/libpng-devel-1.2.8-8.aix5.2.ppc.rpm
libjpeg/libjpeg-6b-6.aix5.1.ppc.rpm
libjpeg/libjpeg-devel-6b-6.aix5.1.ppc.rpm
freetype/freetype-1.3.1-9.aix5.1.ppc.rpm
freetype/freetype-devel-1.3.1-9.aix5.1.ppc.rpm
freetype2/freetype2-2.1.7-5.aix5.1.ppc.rpm
freetype2/freetype2-devel-2.1.7-5.aix5.1.ppc.rpm
libxml2/libxml2-2.6.21-3.aix5.2.ppc.rpm
libxml2/libxml2-devel-2.6.21-3.aix5.2.ppc.rpm
zlib/zlib-1.2.3-4.aix5.2.ppc.rpm
zlib/zlib-devel-1.2.3-4.aix5.2.ppc.rpm
EOF

This really depends on what you want to compile in. My settings will require the stuff listed above.

Also, install fileset bos.adt.libm from the AIX installation media.

4. Download and unpack the latest PHP 5

Download the latest version from:

http://www.php.net/downloads.php#v5

I downloaded 5.2.6. Unpack:

gunzip php-5.2.6.tar.gz
tar xvf php-5.2.6.tar
cd php-5.2.6

5. Configure PHP 5

The AIX toolbox packages have been compiled with a default prefix of /opt/freeware, and that is where all the files from the packages are installed. As we compile php from scratch, it is good practice to configure the php package to go under /usr/local (see the "prefix" below). The "with-config-file-path" sets the the place where PHP searches for its' configuration file.

export PATH=/opt/freeware/bin:$PATH

./configure \
  --prefix=/usr/local \
  --with-config-file-path=/usr/IBMIHS/conf/php.ini \
  --enable-shared \
  --disable-static \
  --enable-maintainer-zts \
  --enable-calendar \
  --enable-bcmath \
  --enable-sockets \
  --enable-zip \
  --with-gd \
  --with-zlib \
  --with-libxml-dir=/opt/freeware \
  --with-zlib-dir=/opt/freeware \
  --with-bz2 \
  --with-gettext=/opt/freeware \
  --with-jpeg-dir=/opt/freeware \
  --with-png-dir=/opt/freeware \
  --with-freetype-dir=/opt/freeware

6. Compile

Compile:

make

You may run into the following errors while compiling:

cc1: out of memory allocating XXX bytes after a total YYY of bytes

This is a ulimit issue. Rise the soft limits to overcome it:

ulimit -S -s 3276800    # stack
ulimit -S -m 13107200  # memory
ulimit -S -d 13107200  # data area

execvp: /bin/sh: The parameter or environment lists are too long.

The parameter list to a command is too long. This limit can be raised. Check out the size with this command:

lsattr -El sys0 -a ncargs

Rise it with this command:

chdev -l sys0 -a ncargs=60

7. Test

make test

8. Install

make install
cp php.ini-recommended /usr/IBMIHS/conf/php.ini

9. Configure IHS

I added the following lines to httpd.conf:

ScriptAlias /php5-cgi /usr/local/bin/php-cgi
Action php-cgi /php5-cgi
AddHandler php-cgi .php

Also, to make index.php work, modify the DirectoryIndex directive:

DirectoryIndex index.html index.html.var index.php

10. Test that everything works

Test the configuration with:

/usr/IBMIHS/bin/apachectl -t

And restart IHS to make the new configuration effective:

/usr/IBMIHS/bin/apachectl restart