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

Links

Using the GNU C/C++ compiler on AIX
http://www.ibm.com/developerworks/aix/library/au-gnu.html
- The authors explain why you should use GCC compiler, which compiler options are specific to pSeries, what you need to know about shared libraries, and common gotchas and solutions.

IBM AIX Toolbox download information
http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/download.html

Hosting PHP Applications on the IBM HTTP Server
http://www.ibm.com/developerworks/opensource/library/os-phphttp/

Raising the command line and environment limit:
http://www.ibm.com/developerworks/forums/thread.jspa?threadID=170563

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • LinkedIn
  • Technorati
  • Google

5 Responses to “Installing PHP 5 on AIX using IBM HTTP Server”

  1. Harie Says:

    Did you come across this error ?
    /home/epdadm/opensource/php/php-5.2.8/ext/pcre/pcrelib/pcre_internal.h:976: error: parse error before ‘BOOL’

    It’s more than one line. I’m guessing if u fix this, u’ll fix it all

    Regards

  2. Yves Says:

    Hi Harie,

    I solved this error as described in the following link:
    http://bugs.php.net/bug.php?id=46040

    edit the file “ext/pcre/pcrelib/pcre_internal.h” as follows:

    ! #ifndef FALSE
    typedef int BOOL;

    #define FALSE 0
    #define TRUE 1
    #endif

    to ==>

    ! #ifndef BOOL
    typedef int BOOL;
    + #endif

    + #ifndef FALSE
    #define FALSE 0
    #define TRUE 1
    #endif

    Hope that helps you, too.
    Regards

  3. Markus Says:

    thanks for the informations provided mikko!

    i’m trying to get it running with aix 6.1 and apache 2.2

    for all followers please be aware you have to change some versions of the aix toolbox, so they fit to your aix version (6.1 in my case), especially the gcc will fail otherwise.

    unfortunately im running into the same error since days: no libphp5.so is generated and therefor the “make install” command crashes:

    ===

    Installing PHP SAPI module: apache2handler
    /usr/local/apache2/build/instdso.sh SH_LIBTOOL=’/usr/local/apache2/build/libtool’ libphp5.la /usr/local/apache2/modules
    rm -f /usr/local/apache2/modules/libphp5.so
    /usr/local/apache2/build/libtool –mode=install cp libphp5.la /usr/local/apache2/modules/
    cp .libs/libphp5.lai /usr/local/apache2/modules/libphp5.la
    cp .libs/libphp5.a /usr/local/apache2/modules/libphp5.a
    chmod 644 /usr/local/apache2/modules/libphp5.a
    ranlib /usr/local/apache2/modules/libphp5.a
    libtool: install: warning: remember to run `libtool –finish /home/install/php-5.2.8/libs’
    Warning! dlname not found in /usr/local/apache2/modules/libphp5.la.
    Assuming installing a .so rather than a libtool archive.
    chmod 755 /usr/local/apache2/modules/libphp5.so
    chmod: /usr/local/apache2/modules/libphp5.so: A file or directory in the path name does not exist.
    apxs:Error: Command failed with rc=65536
    .
    make: *** [install-sapi] Error 1

    ===

    any solutions? :)

  4. geniushome Says:

    Well done, nut phpinfo said:”extension_dir /usr/local/lib/php/extensions/no-debug-zts-20060613″.
    I need to use PDO to connect the DB, how can i update the “extension_dir”?

  5. shrimpnest Says:

    Hi guys,

    I am working on PHP with a AIX 6.1 box too. My friend and I spent a week to make it work. The missing phplib5.so problem was solved by add “–enable-libgcc” to the configure command. I am not sure if it works for your case.

    Now, we are having problem of PCRE. It is not working in AIX while running without problem on Linux and Wins. Does it a bug? any hint? Thanks.

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image