Home arrow Building software arrow Apache & PHP arrow Building Apache & PHP on HP-UX 11.11

Building Apache & PHP on HP-UX 11.11 Print E-mail
User Rating: / 23
PoorBest 
Last Updated: Thursday, 21 December 2006

1. Introduction
     1.1. Modules & extensions
     1.2. Software dependencies
     1.3. Notational conventions
     1.4. Context
     1.5. Pre-requisite
          1.5.1. Patch level
               1.5.1.1. Linker patch
          1.5.2. Software
     1.6. Environment
2. Building
     2.1. Creating the target structure
     2.2. Creating external links
     2.3. Embedding a private libgcc library (4.1.1)
     2.4. Compiling zlib (1.2.3)
     2.5. Compiling OpenSSL (0.9.7i)
     2.6. Compiling OpenLDAP (2.3.27 - 20060823)
     2.7. Compiling expat (2.0.0)
     2.8. Compiling libiconv (1.9.2)
     2.9. Compiling Apache (2.0.59)
     2.10. Compiling mod_jk (tomcat-connectors 1.2.18)
     2.11. Compiling libxml2 (2.6.26)
     2.12. Compiling libxslt (1.1.17)
     2.13. Compiling libpng (1.2.8-config)
     2.14. Compiling libjpeg (v6b)
     2.15. Compiling freetype (2.2.1)
     2.16. Compiling bzip2 (1.0.1)
     2.17. Compiling Curl (7.15.5)
     2.18. Compiling IMAP (4rev1)
     2.19. Compiling MySQL (5.0.24)
     2.20. Compiling PostgreSQL (8.1.4)
     2.21. Compiling mm (1.4.2)
     2.22. Compiling PHP 4 (4.4.4)
     2.23. Compiling PHP 5 (5.1.6)
3. Configuring
     3.1. System
     3.2. Apache
     3.3. Oracle client
     3.4. PHP
     3.5. Start & Stop scripts
4. Checking
     4.1. Starting Apache/PHP
     4.2. Checking the shared library dependencies
     4.3. Checking the PHP modules
5. The end
6. Installing the package

Document history
V 1.0-1 JUN 2006 Creation
V 1.1-1 JUL 2006 Added mod_jk
Added imap
Added RPM creation on Linux
Suppressed AdoDB
V 1.2-1 SEP 2006 Component upgrade to the latest stable versions.
V1.4-4 SEP 2006 Added PHP 4
V 1.4-5 OCT 2006 Added Apache modules : isapi dumpio logio proxy proxy_connect proxy_ftp proxy_http.
Added the mm library (allows to store PHP session information in shmem).
V 1.4-9 NOV 2006 Minor bug corrections and optimizations

1 - Introduction

The goal here is to build a package including every libraries it depends on (except Oracle and system libraries). And everything must be located under a single directory tree.

1.1 - Modules & extensions

We are building Apache 2.0, PHP 4, and PHP 5 with the following modules and extensions :

  • Apache modules :
access actions alias asis auth auth_anon
auth_dbm auth_ldap autoindex cache case_filter case_filter_in
cern_meta cgi cgid charset_lite dav dav_fs
deflate dir disk_cache dumpio echo env
expires ext_filter file_cache headers imap include
info isapi jk (with jni) ldap log_config log_forensic
logio mem_cache mime mime_magic negotiation proxy
proxy_connect proxy_ftp proxy_http rewrite setenvif speling
status suexec ssl unique_id userdir usertrack
vhost_alias PHP 4 PHP 5      

:note These Apache modules are all compiled as shared objects (DSOs).

  • PHP 4 extensions :
bcmath bz2 calendar curl domxml ftp (with ssl)
gd (png, jpeg, freetype) iconv imap ldap mysql oci8
openssl pgsql sockets sysvmsg sysvsem sysvshm
xml zlib        
  • PHP 5 extensions :
bcmath bz2 calendar curl dom ftp (with ssl)
gd (png, jpeg, freetype) iconv imap ldap libxml mysql
mysqli oci8 openssl pdo pdo_mysql pdo_oci
pdo_pgsql pdo_sqlite pgsql shmop simplexml soap
sockets sqlite sysvmsg sysvsem sysvshm xml
xmlreader xmlwriter xsl zlib    

We also include the mm session handler support in PHP 4 & 5 (to be activated with the 'session_handler=mm' directive in php.ini)

1.2 - Software dependencies

The following diagram displays the dependencies between the software packages and libraries we are integrating together.

Sotware dependencies

:note We use the GD bundled library provided in the PHP source packages (4 & 5).

1.3 - Notational conventions

Everything written in red and between '<' and '>' characters must be manually adapted to your configuration.

Everything in black on grey can be copy/pasted as-is.

For instance :

dir=<$BASE>

means that you must replace the '<$BASE>' part with your base directory before typing the line, but :

dir=$BASE

must be entered as-is.

1.4 - Context

Host model : rp4440
OS : HP-UX 11.11 (32-bit)
Date : Nov 2006
Shell : /bin/sh
User : root (not mandatory)
Oracle client : 9.2.0

1.5 - Pre-requisite

1.5.1 - Patch level

1.5.1.1 - Linker patch

The dynamic linker (dld.sl) is severely broken on this version of HP-UX. You will need a patch to fix it.

This document was validated with the PHSS_33035 linker patch installed. Thus, I consider it to be the minimum required patch level. The HP-UX patches are available from HP through the HP ITRC site.

Q: How do I check if my system meets this patch level ?

A: Run the following command on your system :

swlist -l product | grep 'linker tools'

If a linker patch is present, the command should display one or more lines like this one :

PHSS_<number>    1.0    ld(1) and linker tools cumulative patch

  • As these patches are cumulative, if one of the displayed numbers is higher than the minimum patch level, it is OK.
  • If every numbers are lower, it should be upgraded.
  • If the command does not display anything, you don't have any linker patch installed and you should also install the patch.

Please note that this patch level is mandatory on the host where you will compile the package and on every target host where you will run it.

1.5.2 - Software

Product Version Source
gcc 4.1.1 http://hpux.connect.org.uk/
Gettext 0.14.5
Libiconv 1.10
Flex 2.5.4a
GNU make 3.80

1.6 - Environment

First, we set the install directory :

export BASE=<your install directory>

We ensure that the LIBPATH, LD_LIBRARY_PATH, and SHLIB_PATH variables are not set. Only one is used on this system but it is easier to unset them all on every OS :

unset LIBPATH LD_LIBRARY_PATH SHLIB_PATH  || :

If your shell defines alias commands for cp, rm, or mv, you must unalias them now :

unalias cp rm mv || :

Here, we set the variables we use for every software and on every OS. Among others, we ensure that /usr/local/bin is in the PATH :

export BLIB=$BASE/libs
export PKG_CONFIG_PATH="$BLIB/pkg_common"

export CC=gcc
export MAKE=gmake
export CF_OPTS="--enable-shared --disable-static"
export PATH="$PATH:/usr/local/bin:/usr/ccs/bin"

We define where the external modules are located :

export ORACLE_HOME=<your Oracle home>
export JAVA_HOME=<your Java home>

We set the variables specific to this software :

export BAP=$BASE/apache

And we set the variables specific to this environment :

export CPPFLAGS="-I $BLIB/z/include -I $BLIB/ssl/include"

export LDFLAGS="-L$BLIB/common -Wl,+b,$BLIB/common"

And we save these values as reference values :

export REF_LDFLAGS="$LDFLAGS"
export REF_CPPFLAGS="$CPPFLAGS"

2 - Building

2.1 - Creating the target structure

[ -d $BLIB/common ] || mkdir -p $BLIB/common
[ -d $BLIB/pkg_common ] || mkdir -p $BLIB/pkg_common

Now, we create the script that we will use to create symbolic links from a common directory to every library file. This way, we can keep only this directory in the dynamic lib search path (LDFLAGS). We also create links to the pkgconfig files.

export LINKDIR=/tmp/linkdir
echo 'cd $BLIB/$1
cdir=$2
[ -z "$2" ] && cdir=common

for i in *
    do
    if [ -f "$i" ] ; then
        echo "Linking $i"
        /bin/rm -rf $BLIB/$cdir/$i
        ln -s ../$1/$i $BLIB/$cdir/$i
    fi
done

[ -d pkgconfig ] && $LINKDIR $1/pkgconfig pkg_common
exit 0
' >$LINKDIR
chmod +x $LINKDIR

2.2 - Creating external links

We use symbolic links for the external dependencies (Oracle & Java). This way, the path of the symbolic link is constant, and we can move the package anywhere, wherever Oracle and Java are physically installed.

ln -s $ORACLE_HOME $BLIB/oracle
ln -s $JAVA_HOME $BLIB/java

2.3 - Embedding a private libgcc library (4.1.1)

Some files we generate have a runtime dependency on the libgcc shared library file. This file belongs to gcc, which means that, by default, we should have libgcc installed on every runtime host ! Workaround : we include the libgcc shared library file in the final package, and we force the executable files to reference this copy :

mkdir -p $BLIB/gcc/lib
cp -p /usr/local/lib/libgcc_s.sl* $BLIB/gcc/lib
$LINKDIR gcc/lib

:note If you don't have a shared gcc library on your system (as it happens with the gcc package from HP on HP-UX), the best solution is to rebuild gcc (gmake bootstrap builds the shared gcc lib we need).

2.4 - Compiling zlib (1.2.3)

Source : http://www.zlib.net/

./configure --shared --prefix=$BLIB/z

gmake "LDSHARED = gcc -shared $LDFLAGS"
gmake install

 #-- Cleanup

rm -rf $BLIB/z/share $BLIB/z/lib/*.a

$LINKDIR z/lib

2.5 - Compiling OpenSSL (0.9.7i)

Source : http://www.openssl.org/

:note As the configuration process does not use the LDFLAGS environment variable as it should, we have to modify several variables related to the way the libraries will be linked.

./config --openssldir=$BLIB/ssl shared zlib

gmake "SHARED_LDFLAGS = -shared $LDFLAGS" \
    "EX_LIBS = $LDFLAGS -ldld -lz"

gmake install_sw

#-- Cleanup

rm -rf  $BLIB/ssl/man $BLIB/ssl/lib/*.a
$LINKDIR ssl/lib

gmake test "EX_LIBS = $LDFLAGS -ldld -lz"

2.6 - Compiling OpenLDAP (2.3.27 - 20060823)

Source : http://www.openldap.org/

#-- Need to specify OpenSSL location (no configure option)

CC=gcc \
    ./configure --prefix=$BLIB/ldap --without-cyrus-sasl \
    --disable-slapd --disable-slurpd --with-tls=openssl $CF_OPTS

gmake
gmake install

rm -rf $BLIB/ldap/bin $BLIB/ldap/man

$LINKDIR ldap/lib

2.7 - Compiling expat (2.0.0)

Source : http://expat.sourceforge.net/

./configure --prefix=$BLIB/expat $CF_OPTS

gmake
gmake install

#-- Cleanup

rm -rf $BLIB/expat/bin $BLIB/expat/man

$LINKDIR expat/lib

2.8 - Compiling libiconv (1.9.2)

Source : http://www.gnu.org/software/libiconv/

./configure --prefix=$BLIB/iconv $CF_OPTS

gmake
gmake install

rm -rf $BLIB/iconv/bin $BLIB/iconv/share/doc \
    $BLIB/iconv/share/man

$LINKDIR iconv/lib

2.9 - Compiling Apache (2.0.59)

Source : http://httpd.apache.org/ 

:note We compile Apache in 3 steps because our LDAP package is not in the standard location.

:note Please refer to 'compiling PHP' below for an explanation of the LDFLAGS setting.

:note The configure stage does not detect OpenSSL, as it does not detect the '.sl' suffix for shared libraries. Bug reported to the Apache Dev as #40917. Workaround : we create a fake 'libssl.so' file in the OpenSSL lib directory.

:note If you want to build the auth_digest module, you need to install the 'HP-UX Strong Random Number Generator' package from HP (ref. KRNG11i) avilable free of charge from http://software.hp.com. This package creates the /dev/[u]random pseudo-devices used for better random number generation, and required by auth_digest. Once it is installed, you can add 'auth_digest' to the list of modules of the configure command below and remove the 'disable-auth-digest' directive. Note that, at runtime, the auth_digest module also requires the KRNG11i package to be installed on the target hosts.

export LDFLAGS="$LDFLAGS -lcl"

ln -s libssl.sl $BLIB/ssl/lib/libssl.so

#-- Build apr

cd srclib/apr
./configure --prefix=$BAP --enable-threads $CF_OPTS

gmake
gmake install

#-- Build apr-util

cd ../apr-util
./configure --prefix=$BAP $CF_OPTS\
    --with-ldap \
    --with-ldap-lib=$BLIB/ldap/lib \
    --with-ldap-include=$BLIB/ldap/include \
    --with-iconv=$BLIB/iconv \
    --with-expat=$BLIB/expat \
    --with-apr=$BAP

gmake
gmake install

#-- Build Apache

cd ../..
./configure --prefix=$BAP \
    --enable-mods-shared="all cache case-filter case-filter-in cgid \
       charset-lite deflate disk-cache echo file-cache \
       mem-cache suexec ldap auth-ldap ssl isapi\
       dumpio logio proxy proxy_connect proxy_ftp proxy_http" \
    --disable-auth-digest \
    --with-perl=/usr/bin/perl \
    --with-z=$BLIB/z \
    --with-ssl=$BLIB/ssl \
    --with-iconv=$BLIB/iconv \
    --with-expat=$BLIB/expat \
    --with-apr=$BAP \
    --with-apr-util=$BAP\
         2>&1 | tee configure.log

gmake
gmake install
chown -Rh root:sys $BAP

export LDFLAGS="$REF_LDFLAGS"

chown -Rh root:sys $BAP

2.10 - Compiling mod_jk (tomcat-connectors 1.2.18)

Source : http://tomcat.apache.org/download-connectors.cgi

:note Gcc version 4 is more restrictive than version 3. As such, some of the HP-UX system include files fail when compiled with it. This is the case for /usr/include/sys/socketvar.h, which, unfortunately, is included by the mod_jk source files. In order to work around this issue without modifying the include file in /usr/include/sys, we create a modified version especially for gcc (adapt the path to your GCC version) :

cp /usr/include/sys/socketvar.h \
        /usr/local/lib/gcc/hppa2.0w-hp-hpux11.11/4.1.1/include/sys
cd $_
vi socketvar.h
cd ~-

Go to line 492 and change :

extern struct sotimeq sotimeqhash[];
extern lock_t *sotimeq_lock;

struct sotimeq {
        struct sotimeq *sotimeq_next;
        struct sotimeq *sotimeq_prev;
        int sotimeq_dtime;
        caddr_t sotimeq_wchan;
};

to :

extern lock_t *sotimeq_lock;

struct sotimeq {
        struct sotimeq *sotimeq_next;
        struct sotimeq *sotimeq_prev;
        int sotimeq_dtime;
        caddr_t sotimeq_wchan;
};
extern struct sotimeq sotimeqhash[];

Then, we proceed quite the usual way :

cd native

CFLAGS="$CPPFLAGS -DHPUX11GCC -DHPUX11" \
    ./configure --with-apxs=$BAP/bin/apxs \
    --with-java-home=$BLIB/java \
    --enable-jni

gmake
gmake install

cd ..

These command compile and install a mod_jk.so file in $BAP/modules.

2.11 - Compiling libxml2 (2.6.26)

Source : http://xmlsoft.org/

./configure --prefix=$BLIB/xml2 \
    --with-iconv=$BLIB/iconv \
    --with-zlib=$BLIB/z $CF_OPTS

gmake
gmake install

rm -rf $BLIB/xml2/man $BLIB/xml2/share $BLIB/xml2/bin/xmlcatalog \
    $BLIB/xml2/bin/xmllint $BLIB/xml2/lib/python2.2

$LINKDIR xml2/lib

2.12 - Compiling libxslt (1.1.17)

Source : http://xmlsoft.org/XSLT/

./configure --prefix=$BLIB/xslt \
    --with-libxml-prefix=$BLIB/xml2 $CF_OPTS

gmake
gmake install

/bin/rm -rf $BLIB/xslt/man $BLIB/xslt/share $BLIB/xslt/bin/xsltproc

$LINKDIR xslt/lib

2.13 - Compiling libpng (1.2.8-config)

Source : http://libpng.sourceforge.net/

./configure --prefix=$BLIB/png $CF_OPTS

gmake
gmake install

rm -rf $BLIB/png/man

$LINKDIR png/lib

Then, we must modify the files libpng-config and libpng12-config in $BLIB/png/bin. In these 2 files, we replace the '-rpath' linker option (Linux specific) with '+b' (the corresponding option for this system) :

for i in libpng-config libpng12-config
    do
    sed -e 's/-Wl,-rpath/-Wl,+b/' <$BLIB/png/bin/$i >tmp1
    cp tmp1 $BLIB/png/bin/$i
    chmod +x $BLIB/png/bin/$i
done

2.14 - Compiling libjpeg (v6b)

Source : http://www.ijg.org/files

:note As the libtool we get with this package is unable to build a shared library on HP-UX, we have to do it another way :

CPPFLAGS="$CPPFLAGS -fPIC" \
    ./configure --prefix=$BLIB/jpeg $CF_OPTS

#-- Build the static library and install include files

gmake clean libjpeg.la install-headers

#-- Build the dynamic lib and install it

gcc -shared -o libjpeg.sl *.o $LDFLAGS
./install-sh -c -m 755 libjpeg.sl $BLIB/jpeg/lib/libjpeg.sl
sed -e "s/\(dlname=\)''/\1'libjpeg.sl'/" \
    -e "s/\(library_names=\)''/\1'libjpeg.sl'/" \
    -e "s/\(old_library=\)'.*\$/\1''/" <libjpeg.la >$BLIB/jpeg/lib/libjpeg.la

$LINKDIR jpeg/lib

2.15 - Compiling freetype (2.2.1)

Source : http://www.freetype.org/index2.html

:note On some OS, freetype seems to be incompatible with our version of zlib (don't know why it does not happen on every OS). Workaround: we systematically use the embedded zlib library.

#-- Build process needs GNU make (and a GNUMAKE variable)

GNUMAKE=gmake \
    ./configure --prefix=$BLIB/freetype --without-zlib $CF_OPTS

gmake
gmake install

$LINKDIR freetype/lib

2.16 - Compiling bzip2 (1.0.1)

Source : http://www.digistar.com/bzip2/

:note Here, we have to modify the makefile before compiling in order to remove some invalid options.

:note As the current makefile does not use our LDFLAGS settings, we must link the shared library with our own command.

:note We also must install the files manually as the Makefile is unable to do it.

#-- Modify the Makefile

sed 's/-Wl,-soname -Wl,libbz2.so.1.0//' <Makefile-libbz2_so >tmp1
cp tmp1 Makefile-libbz2_so

#-- Build

gmake -f Makefile-libbz2_so
gcc -shared -o libbz2.so.1.0.1 $LDFLAGS *.o

#-- Install

mkdir -p $BLIB/bz2/include $BLIB/bz2/lib
cp bzlib.h $BLIB/bz2/include
cp libbz2.so.1.0.1 $BLIB/bz2/lib/libbz2.sl.1.0.1
ln -s libbz2.sl.1.0.1 $BLIB/bz2/lib/libbz2.sl.1.0
ln -s  libbz2.sl.1.0 $BLIB/bz2/lib/libbz2.sl.1
ln -s libbz2.sl.1 $BLIB/bz2/lib/libbz2.sl

$LINKDIR bz2/lib

2.17 - Compiling Curl (7.15.5)

Source : http://curl.haxx.se/

./configure --prefix=$BLIB/curl \
    --with-zlib=$BLIB/z --with-ssl=$BLIB/ssl $CF_OPTS

gmake
gmake install

rm -rf $BLIB/curl/share/man $BLIB/curl/bin/curl

$LINKDIR curl/lib

2.18 - Compiling IMAP (4rev1)

Source : http://www.imap.org

:note The IMAP distribution does not provide a way to build a shared client library. So, we do it our way : we build the static library first, with the '-fPIC' compile flag to generate relocatable objects, and, then, we build the shared library from these objects.

:note We have to provide the MD5ENABLE definition because it is not provided on this OS.

:note We need a libc-client.a file in $BLIB/imap/lib because the PHP configure process specifically tests for the presence of this file. So, we create it as a symbolic link.

#-- Modify the Makefiles for SSL location

sed "s!/usr/local/ssl!$BLIB/ssl!g" <src/osdep/unix/Makefile >tmp1
cp tmp1 src/osdep/unix/Makefile

sed -e "s,/usr/include/openssl,$BLIB/ssl/include,g" \
    -e "s,/usr/share/ssl,$BLIB/ssl,g" \
    -e "s,SSLLIB=/usr/lib,SSLLIB=$BLIB/ssl/lib,g" <Makefile >tmp1
cp tmp1  Makefile

#-- Build a static library

gmake ghp "MAKE = gmake" "EXTRACFLAGS = -fPIC -DMD5ENABLE=\"\"" \
    "EXTRASPECIALS = CC=gcc"

#-- Build the dynamic one

cd c-client
gcc  -shared -o libc-client.sl *.o $LDFLAGS -lssl -lcrypto -ldld -lz

#-- Install the headers and the library
#-- PHP configure needs a '.a' file

mkdir -p $BLIB/imap/lib $BLIB/imap/include
cp libc-client.sl $BLIB/imap/lib
ln -s libc-client.sl $BLIB/imap/lib/libc-client.a
cp *.h $BLIB/imap/include

cd ..

$LINKDIR imap/lib

2.19 - Compiling MySQL (5.0.24)

Source : http://www.mysql.com/

:note Because of bug #21327, we have to modify the configure script before running it if we want to use OpenSSL from a non-standard location. This bug is supposed to be fixed in version 5.0.25. Here is a quick and dirty hack to fix it until then :

sed -e 's!\$d/libssl!$libs/libssl!g' <configure >configure.new
cp configure.new configure
chmod +x configure

CXX=gcc \
    ./configure --prefix=$BLIB/mysql $CF_OPTS \
    --enable-thread-safe-client \
    --with-zlib-dir=$BLIB/z \
    --with-openssl=$BLIB/ssl \
    --without-debug \
    --without-server \
    --without-extra-tools \
    --without-docs \
    --without-man \
    --without-bench 2>&1 | tee configure.log

gmake
gmake install

#-- Cleanup

rm -rf $BLIB/mysql/bin/* $BLIB/mysql/libexec $BLIB/mysql/mysql-test
cp scripts/mysql_config $BLIB/mysql/bin

#-- Remove server libraries

for i in dbug heap myisam myisammrg mystrings mysys vio
    do rm -f $BLIB/mysql/lib/mysql/lib$i.*
done

$LINKDIR mysql/lib/mysql

2.20 - Compiling PostgreSQL (8.1.4)

Source : http://www.postgresql.org/

The configure process does not use CPPFLAGS and LDFLAGS correctly (the problem only appears when the libraries are not installed in the usual locations). As a workaround, we feed it with modified values for some other environment variables.

LDFLAGS_SL="-L$BLIB/common" \
    CFLAGS="$CPPFLAGS" \
    CPP="gcc -E $CPPFLAGS" \
    ./configure --prefix=$BLIB/pgsql $CF_OPTS \
    --without-docdir \
    --without-tcl \
    --with-openssl \
    --without-readline \
    --with-zlib

gmake
gmake install

#-- Cleanup

rm -rf $BLIB/pgsql/bin/* $BLIB/pgsql/man $BLIB/pgsql/include/server \
    $BLIB/pgsql/lib/*.a

cp src/bin/pg_config/pg_config $BLIB/pgsql/bin

$LINKDIR pgsql/lib

2.21 - Compiling mm (1.4.2)

Source : http://www.ossp.org/pkg/lib/mm/

:note Here, the Makefile does not use the LDFLAGS variable, but we absolutely need it to specify the library search path. So, we have to use an ugly workaround... (Feature request #122 sent to the mm maintainers)

./configure --prefix=$BLIB/mm $CF_OPTS

gmake "libdir = $BLIB/mm/lib $LDFLAGS"
gmake install

rm -rf $BLIB/mm/share

$LINKDIR mm/lib

2.22 - Compiling PHP 4 (4.4.4)

Source : www.php.net

:note PHP 4 finds Oracle libraries in $ORACLE_HOME/lib. But we are on a 32 bit environment and the corresponding libraries are in $ORACLE_HOME/lib32. This bug has been corrected a long time ago on PHP 5 but it seems to be still present in version 4. Workaround : we modify the Makefile after the configure stage.

:note During installation, PHP inserts a 'LoadModule' line in httpd.conf. As we cannot have both PHP modules loaded at the same time, we decide that the default PHP module will be PHP 5. So, we comment out the PHP 4 LoadModule directive in the httpd.conf configuration file.

:note See the next chapter for an explanation about LDFLAGS and libcrypt.

export PBASE=$BASE/php4

ORA_CF=''
if [ "$ORACLE_HOME" != 'none' ] ; then \
    if [ -d "$ORACLE_HOME/sdk" ] ; then    #-- InstantClient
        ORA_CF="--with-oci8-instant-client=shared,$BLIB/oracle"
    else    #-- Standard client
        ORA_CF="--with-oci8=shared,$BLIB/oracle"
    fi
fi

[ -f /usr/lib/libcrypt.a ] && \
    mv /usr/lib/libcrypt.a /usr/lib/libcrypt.a.save

export LDFLAGS="$LDFLAGS -lcl"

./configure --prefix=$PBASE \
    --with-config-file-path=$PBASE \
    --with-apxs2=$BAP/bin/apxs \
    --with-zlib=shared,$BLIB/z \
    --with-zlib-dir=$BLIB/z \
    --with-bz2=shared,$BLIB/bz2 \
    --enable-ftp=shared \
    --enable-dom \
    --with-iconv=shared,$BLIB/iconv \
    --with-iconv-dir=$BLIB/iconv \
    --enable-calendar=shared \
    --enable-sockets=shared \
    --enable-bcmath=shared \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-sysvmsg \
    --with-openssl=shared,$BLIB/ssl \
    --with-openssl-dir=$BLIB/ssl \
    --with-curl=shared,$BLIB/curl \
    --with-ldap=shared,$BLIB/ldap \
    --with-gd=shared \
    --with-png-dir=$BLIB/png \
    --with-jpeg-dir=$BLIB/jpeg \
    --enable-gd-native-ttf \
    --with-freetype-dir=$BLIB/freetype \
    --with-mysql=shared,$BLIB/mysql \
    --with-pgsql=shared,$BLIB/pgsql \
    --with-imap=shared,$BLIB/imap \
    --with-imap-ssl=$BLIB/ssl \
    --with-dom-xslt=$BLIB/xslt \
    --with-dom-exslt=$BLIB/xslt \
    --with-dom=$BLIB/xml2 \
    --with-expat-dir=$BLIB/expat \
    --with-mm=$BLIB/mm \
    $ORA_CF \
        2>&1 | tee configure.log

#-- Modify the Oracle lib path in the Makefile

_oralibdir=lib
if [ -d $BLIB/oracle/lib32 ] ; then
    _oralibdir=lib32
    sed 's!oracle/lib !oracle/lib32 !g' <Makefile >tmp1
    cp tmp1 Makefile
fi

#-- Build & install

gmake
gmake install

#-- Comment out the LoadModule directive

sed 's/^LoadModule php4/#LoadModule php4/' <$BAP/conf/httpd.conf >tmp1
cp tmp1 $BAP/conf/httpd.conf

mv /usr/lib/libcrypt.a.save /usr/lib/libcrypt.a    # restore this f... libcrypt.a

export LDFLAGS="$REF_LDFLAGS"

#-- Move extensions (personal, I don't like this 'no-debug...' dir)

cd $PBASE/lib/php/extensions
mv */* .
rmdir no-debug*
cd ~-

#-- Install default configuration file

cp php.ini-recommended $PBASE/php.ini

2.23 - Compiling PHP 5 (5.1.6)

Source : www.php.net

If your compilation fails with a message starting with 'cc1: out of memory...', increase the value of your maxdsiz kernel configurable parameter (this operation requires root privilege and reboots the host). Typically, using gcc 4.1.1, a value of 100,000,000 (100 Mbytes) was large enough, even when using the gcc '-O3' flag.

:note Issue with libcl (Can't dlopen() a library containing Thread Local Storage). Because of this problem, we cannot dlopen() the Oracle extensions (oci8 and pdo_oci) because they indirectly reference libcl, which uses some thread local storage. Reference of the document describing this problem in the HP ITRC website : AUSRCKBAN00000314. PHP bug #13151. I don't think that it will be fixed soon as it is not really a problem of PHP. Workaround : The executable file which does the dlopen() call must have been linked with the library using TLS (libcl here). Here, that means that we must link the apache and php executable files with a -lcl option. That's why we set LDFLAGS='-lcl'.

:note Ignore this error message from configure : './configure[75167]: pkg-config:  not found.'. It is a configure bug reported to the PHP Dev team as #35981. This error does not seem to have any influence on the rest of the build process.

:note HP-UX contains an empty library /usr/lib/libcrypt.a. But the crypt() function is in libc. Because of the libcrypt.a file, configure decides to include it in the linker flags. And, later, as there is no libcrypt.sl file, PHP refuses to build some modules in shared mode. Workaround : we temporarily rename the file.

export PBASE=$BASE/php5

#-- Set Oracle configure options

ORA_CF=''
if [ "$ORACLE_HOME" != 'none' ] ; then \
    if [ -d "$ORACLE_HOME/sdk" ] ; then    #-- InstantClient
        ORA_CF="--with-oci8=shared,instantclient,$BLIB/oracle \
            --with-pdo-oci=shared,instantclient,$BLIB/oracle,10.2"
    else    #-- Standard client
        ORA_CF="--with-oci8=shared,$BLIB/oracle \
            --with-pdo-oci=shared,$BLIB/oracle"
    fi
fi
#-- Undocumented option - disables Oracle support in PHP5
#-- (and keeps it enabled for PHP4). Use if you want to compile PHP4 against
#-- a pre-9.0 version of Oracle (which is not supported by PHP5).

[ -n "$DISABLE_PHP5_ORA" ] && ORA_CF=''

[ -f /usr/lib/libcrypt.a ] && \
    mv /usr/lib/libcrypt.a /usr/lib/libcrypt.a.save

export LDFLAGS="$LDFLAGS -lcl"

./configure --prefix=$PBASE \
    --with-config-file-path=$PBASE \
    --with-apxs2=$BAP/bin/apxs \
    --with-zlib=shared,$BLIB/z \
    --with-zlib-dir=$BLIB/z \
    --with-bz2=shared,$BLIB/bz2 \
    --enable-ftp=shared \
    --with-libxml=$BLIB/xml2 \
    --with-xml=$BLIB/xml2 \
    --with-libxml-dir=$BLIB/xml2 \
    --with-xsl=shared,$BLIB/xslt \
    --enable-dom \
    --enable-simplexml \
    --with-iconv=shared,$BLIB/iconv \
    --with-iconv-dir=$BLIB/iconv \
    --enable-calendar=shared \
    --enable-sockets=shared \
    --enable-soap=shared \
    --enable-bcmath=shared \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-shmop \
    --enable-sysvmsg \
    --enable-pdo=shared \
    --with-pdo-sqlite=shared \
    --with-sqlite=shared \
    --enable-sqlite-utf8 \
    --with-openssl=shared,$BLIB/ssl \
    --with-openssl-dir=$BLIB/ssl \
    --with-curl=shared,$BLIB/curl \
    --with-ldap=shared,$BLIB/ldap \
    --with-gd=shared \
    --with-png-dir=$BLIB/png \
    --with-jpeg-dir=$BLIB/jpeg \
    --enable-gd-native-ttf \
    --with-freetype-dir=$BLIB/freetype \
    --with-mysql=shared,$BLIB/mysql \
    --with-mysqli=shared,$BLIB/mysql/bin/mysql_config \
    --with-pdo-mysql=shared,$BLIB/mysql \
    --with-pgsql=shared,$BLIB/pgsql \
    --with-pdo-pgsql=shared,$BLIB/pgsql \
    --with-imap=shared,$BLIB/imap \
    --with-imap-ssl=$BLIB/ssl \
    --with-mm=$BLIB/mm \
    $ORA_CF \
        2>&1 | tee configure.log

#-- Build

gmake
gmake install

mv /usr/lib/libcrypt.a.save /usr/lib/libcrypt.a    # restore this f... libcrypt.a

export LDFLAGS="$REF_LDFLAGS"
#-- Move extensions (personal, I don't like this 'no-debug...' dir)

cd $PBASE/lib/php/extensions
mv */* .
rmdir no-debug*
cd ~-

#-- Install default configuration file

cp php.ini-recommended $PBASE/php.ini

3 - Configuring

Here, we give only a minimal configuration, which allows to start Apache/PHP, and to run the test we give below. When the package is installed on a target machine, it must be configured in a much more serious way. But this aspect is beyond the scope of this document.

:call

Warning : Running this package with the default configuration in a production environment can lead to serious performance and security problems !!
You have been warned

3.1 - System

  • Check that a www user exists in /etc/passwd. If not, create it with passwd='*' and login shell = /bin/false.
  • Add a www group in /etc/group if it does not already exist.

3.2 - Apache

Edit $BAP/conf/httpd.conf :

  • Change the line starting with 'User' to 'User www'
  • Change the line containing 'Group #-1' to 'Group www'.
  • Add this line anywhere in the file :

AddType application/x-httpd-php .php

Add the following line at the end of $BAP/bin/envvars :

unset LD_LIBRARY_PATH LIBPATH SHLIB_PATH

In order to avoid a problem of Apache crashing on HP-UX (message 'cannot grab mutex'), HP recommends to add this line to the configuration. The only thing I can say is that it solved the problem for me.

AcceptMutex fcntl

3.3 - Oracle client

Edit the file '$BAP/bin/envvars' and add the environment variables needed by the Oracle client :

ORACLE_HOME=<$BASE>/libs/oracle
export ORACLE_HOME

#-- TNS_ADMIN is optional, set only if you don't use the default
#-- location ($ORACLE_HOME/network/admin)

TNS_ADMIN=<directory>
export TNS_ADMIN

3.4 - PHP

For each PHP version, edit $BASE/php{4,5}/php.ini :

extension_dir = "<$BASE>/php/lib/php/extensions"

3.5 - Start & Stop scripts

cd $BASE
mkdir system
cd system

Create a file named apache in this directory. Its mode is 755 and it contains the following code :

# Apache/PHP start/stop script
#
# chkconfig: 2345 99 05
# description: Apache/PHP Web server
#
# V 1.3 (29-AUG-2006)
#
#============================================================================

export APACHE_HOME=<$BASE>

export PATH=/usr/sbin:/usr/bin:/sbin:$PATH

case $1 in
'start_msg') echo "Starting Apache Web Server";;
'stop_msg') echo "Stopping Apache Web Server";;

'start')
    # Check to see if apache is allowed to start...
    $APACHE_HOME/apache/bin/apachectl start && exit 0
    echo "** ERROR: Could not start Apache"
    exit 1
    ;;
   
'stop')
    $APACHE_HOME/apache/bin/apachectl stop >/dev/null 2>&1
    exit 0
    ;;
   
*)
    echo "usage: $0 {start|stop|start_msg|stop_msg}"
    exit 1
    ;;
esac

#============================================================================

4 - Checking

4.1 - Starting Apache/PHP

Now, start Apache with :

<$BASE>/system/apache start

This should not display any message.

4.2 - Checking the shared library dependencies

unset LIBPATH SHLIB_PATH LD_LIBRARY_PATH
cd $BASE
for i in `find . -type f`
    do
    ldd $i 2>/dev/null
done \
    | sed -e 's!^.*>[[:space:]]*!!' -e 's!\.[0-9]$!!' \
    | grep -v '/libwtc.\.sl$' \
    | grep -v '^/usr/lib/dld.sl: No such file or directory$' \
    | grep -v '^/usr/lib/libnss_dns$' \
    | sort -u \
    | grep -v "^$BASE/"

This script must display only the following system libraries :

  • /usr/lib/libc
  • /usr/lib/libcl
  • /usr/lib/libdld
  • /usr/lib/libgen
  • /usr/lib/libisamstub
  • /usr/lib/libm
  • /usr/lib/libnsl
  • /usr/lib/libpam
  • /usr/lib/libpthread
  • /usr/lib/librt
  • /usr/lib/libxnet
  • /usr/lib/libxti

4.3 - Checking the PHP modules

Here, we just check that the PHP shared modules can be loaded without error. This check should be done every time you install your package to a new host, as it allows to check that every shared lib dependencies are satisfied.

The syntax of this script must be compatible with PHP versions 4 & 5. That's why we cannot use scandir().

By default, you will be testing PHP 5. In order to test your PHP 4 installation, comment out the PHP5 line in $BAP/conf/httpd.conf, uncomment the PHP4 line, restart Apache, and reload the page from your browser.

Create a new file named $BAP/htdocs/test.php with the following content :

<?php
error_reporting(E_ALL);
ini_set('display_errors',true);

$libs=array();
$dir=opendir(ini_get('extension_dir'));
while ($lib=readdir($dir))
    {
    if (fnmatch('*.'.PHP_SHLIB_SUFFIX,$lib)) $libs[]=$lib;
    }

sort($libs);
foreach($libs as $lib)
    {
    echo "Loading module $lib ...<br>";
    dl($lib);
    }

phpinfo();
?>

From your browser, display this page (URL = http://<your_server>/test.php).

It displays the configuration of every PHP modules, static and dynamic. If there are some errors when trying to load a module, it will also display them.

5 - The end

Congratulations !

Now, you have a complete Apache/PHP package in your $BASE directory. The last step is to tar and compress it to a package file.

6 - Installing the package

In order to install the package to a target host :

  • Uncompress and untar the package file on the target host in the same directory as the source host ($BASE)
  • Check that a www user exists in /etc/passwd. If not, create it with passwd='*' and login shell = /bin/false.
  • Add a www group in /etc/group if it does not already exist.
  • Check the shared lib dependencies (see above)
  • Create 3 symbolic links :

ln -s <$BASE>/system/apache /sbin/init.d/apache
ln -s ../init.d/apache /sbin/rc2.d/K176apache
ln -s ../init.d/apache /sbin/rc3.d/S824apache

  • Configure Apache ($BAP/conf) and PHP ($BASE/php{4,5}/php.ini)
  • Start Apache with : /sbin/init.d/apache start
  • Check the PHP modules (see above)
  • :love Enjoy !

Comments
Written by Guest on 2006-03-28 10:11:29 IP: 81.255.174.7
А на русском? 
RE: Огорченный, я не говорю по-русски
imap
Written by Guest on 2006-07-26 16:21:20 IP: 81.255.174.7
What about imap vs php ? 
RE: The new version of this document (published on 26-JUL-2006) includes the IMAP extension.
HP-UX 11.23 PA-RISC
Written by klips on 2006-05-04 22:14:06 IP: 82.240.16.115
Great Documentation... 
 
I have just downloaded everything mentioned. We have been trying to figure out how to get all this to run independantly to shared libraries on each server. We support over 50+ internal servers. For years, we have been living with apache 1.x, NO PHP, or anything else. All due to the fact that we push our internal application to a HP-UX system and flip the switch. We have all of our self written code and packages like apache within a single directory structure off of the root directory. Everything that we count on resides 99% internally to that directory structure. 
 
If everything that you have accomplished here works for us, you'll be putting us back into the mainstream of features that we desparately need. 
Now I am going to be trying to get this compiled and put together on an HP-UX 11.23 PA-RISC system. One of the pre-requisites calls for X11MotifDevKit. This seems to be part of the purchased HP ANSI C compiler. How important is this to completing the process? 
 
Re: The Motif dev kit is used only when compiling libXpm. If you don't build libXpm, you remove Xpm format support from the GD library (which is not critical for most users). 
 
We want what is commonly referred to as gd2. I am assuming that this is what you are in "Annexes - Optional" Section of the documentation. Am I correct? 
 
Re: No, PHP includes a bundled version of the GD library (GD2). Most people will take this version and this is what I use in my procedure. The 'annexes' part must be used only if you want to use another (unbundled) version of the GD library, which is certainly not your case. 
 
And in looking at the options for compiling MySQL, is this going to generate a fully functional installation of MySQL? We are definitely looking to include MySQL into our package. If this doesn't give us a complete installation, do you have any recommendations on what to change in the configure to provide us with a working version? 
 
Re: the procedure I give in the article builds a fully functional MySQL client for PHP. But it contains an 'rm' line which suppresses everything which is useless from a PHP point of view. If you want to keep all the tools, examples, static libs,... in your MySQL client, don't 'rm' anything. And if you want to build more than the client, change the configure line. 
 
Any advice would be greatly appreciated. I'm not for compiling these things on my own. I am at the mercy of the community that knows how all this works. 
 
Re: Please note that, as a freelance IT consultant, I would be glad to work on a customized version for your company. Feel free to contact me for more details. 
 
Thanks!
successful compile on HP-UX 11.11
Written by eberhard on 2006-05-04 21:54:16 IP: 82.240.16.115
Thanks for this really great work! I have spent endless hours in useless attempts to compile PHP on HP-UX 11.11 before I found this documentation. Using the precompiled version of HP was not an option for me, because I need additional modules like SQL-Server support. 
However I have 2 questions: 
1. You don't say anything about using the 32 or 64 bit version of HP-UX. I was not able to compile it on a 64 bit environment. 
 
Re: Yes, I only tried it on 32-bit environments. I will try to find some time to build on 64-bit. 
 
2. Although I used the linker flags LDFLAGS="-lcl" I experienced the 'dl_open() problem' you described, especially when loading the oci8 module. Only chance to fix this was in the envvar file of apache with LD_PRELOAD=/usr/lib/libpthread.sl:$ORACLE_HOME/lib/libclntsh.sl 
Do you have any suggestions on this? 
 
Re: No, it should work with '-lcl' specified at link time. In order to see if the flag was really used, try to 'ldd' apache/bin/httpd and php/bin/php. You should see libcl in the result. And, if you see it, you shouldn't meet the 'dlopen' problem. Please tell me what this test gives. I avoided the LD_PRELOAD solution because it is a good solution for PHP through Apache, but not a very clean one for PHP in CLI mode. 
 
However, most important is it works now. 
One remark to the question of klips concering the X11MotifDevKit (HP Number B3394BA) 
This is not part of the HP ANSI C compiler, it is only on the same CD but available for free. 
 
Best regards 
Eberhard
successful compile on HP-UX 11.11
Written by eberhard on 2006-05-08 07:57:34 IP: 213.30.210.210
See below the output of ldd apache/bin/httpd. 
Seems as it would be correct, but I must confess I am confused with this stuff :-) 
Best regards 
Eberhard 
 
/usr/lib/libc.2 => /usr/lib/libc.2 
/usr/lib/libdld.2 => /usr/lib/libdld.2 
/usr/lib/libc.2 => /usr/lib/libc.2 
/usr/lib/libdld.2 => /usr/lib/libdld.2 
/usr/lib/libpthread.1 => /usr/lib/libpthread.1 
/usr/lib/libnsl.1 => /usr/lib/libnsl.1 
/usr/lib/libxti.2 => /usr/lib/libxti.2 
/usr/lib/libm.2 => /usr/lib/libm.2 
/usr/lib/libcl.2 => /usr/lib/libcl.2 
/usr/lib/libisamstub.1 => /usr/lib/libisamstub.1 
/usr/lib/libdld.2 => /usr/lib/libdld.2 
/opt/apache/lib/libapr-0.sl.9 => /opt/apache/lib/libapr-0.sl.9 
/usr/lib/libc.2 => /usr/lib/libc.2 
/usr/lib/libdld.2 => /usr/lib/libdld.2 
/usr/lib/libpthread.1 => /usr/lib/libpthread.1 
/usr/lib/libnsl.1 => /usr/lib/libnsl.1 
/usr/lib/libm.2 => /usr/lib/libm.2 
/usr/lib/libcl.2 => /usr/lib/libcl.2 
/opt/libs/iconv/lib/libiconv.sl.4 => /opt/libs/iconv/lib/libiconv.sl.4 
/usr/lib/libc.2 => /usr/lib/libc.2 
/opt/libs/expat/lib/libexpat.sl.5 => /opt/libs/expat/lib/libexpat.sl.5 
/usr/lib/libc.2 => /usr/lib/libc.2 
/opt/apache/lib/libaprutil-0.sl.9 => /opt/apache/lib/libaprutil-0.sl.9 
/usr/lib/libc.2 => /usr/lib/libc.2 
/usr/lib/libcl.2 => /usr/lib/libcl.2 
/opt/libs/z/lib/libz.sl => /opt/libs/z/lib/libz.sl 
Written by Sriyanto on 2006-12-13 03:49:23 IP: 202.134.2.102
Thanks, I successfully installed Apache, PHP with oci8 support 
but i have a problem. 
 
some time i get error while try to connect to oracle with error ORA-12533 
i already check that oracle server and listener is up, and TNSNAMES are valid. 
 
Do you have any suggestions on this?
Written by Theo on 2007-01-05 17:32:45 IP: 129.57.8.153
It appears that it is possible to compile PHP 5.1.2 against the Oracle 10.2 client (full or instantclient), but all later versions (I tested 5.1.4, 5.1.6, 5.2.0) will all fail to compile with an error similar to the following: 
 
/ext/oci8/php_oci8_int.h:343: error: expected declaration specifiers or '...' before 'oraub8' 
 
The php developers have pointed the finger at Oracle (see PHP bug 39178) who do not yet appear to have addressed it yet under the guise of Oracle bug 4901517 
 
Since this guide suggests you have succesfully compiled 5.1.6 against Oracle 9.2 client, I will next try compiling 5.2.0 against that older version of Oracle. 
Big Thanks!
Written by Dirk on 2007-01-23 15:16:01 IP: 217.5.231.249
Works like a charm on HP-UX 11.11! 
I had to downgrade to php 5.0.5 in the need of those native informix functions, but apart from that, everything works fine.
HP-UX 11.23
Written by THom Fitzpatrick on 2007-03-22 16:18:52 IP: 64.162.28.162
Thanks for the tips. I finally got this $%!@#%$ PHP to compile on 11.23 with gcc 4.1.1 and gmake 3.81 
 
I didn't have to munge the libtool file 
 
PREFIX=/usr/local 
./configure \ 
--enable-shared \ 
--prefix=$PREFIX \ 
--disable-debug \ 
--with-apache2=$PREFIX/httpd \ 
--with-apxs2=$PREFIX/httpd/bin/apxs \ 
--with-config-file-path=/etc:$PREFIX/lib/php \ 
--with-xml \ 
--with-zlib \ 
--with-libxml-dir=$PREFIX/lib \ 
--with-mysql=/usr/local/mysql \ 
--with-config-file-path=$PREFIX/httpd/php \ 
--enable-force-cgi-redirect \ 
--disable-cgi \ 
--with-zlib \ 
--without-pear \ 
--libexecdir=/usr/local/libexec 

Only registered users can write comments.
Please login or register.

Powered by AkoComment!


All site content is (C) F. Laupretre (wishlist) - Unauthorized reproduction forbidden without express written permission.
Joomla! is Free Software released under the GNU/GPL License. - Template design: JLM@joomlabox