|
| 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 :
These Apache modules are all compiled as
shared
objects (DSOs).
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.

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 :
means that you must replace the '<$BASE>' part with your base directory before
typing the line, but :
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
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 :
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 :
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 |
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/
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/
We compile Apache in 3 steps because our LDAP package is not in the
standard location.
Please refer to 'compiling PHP' below for an explanation of the LDFLAGS
setting.
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.
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
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
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
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/
Here, we have to modify the makefile before compiling in order to
remove some invalid options.
As the current makefile does not use our LDFLAGS
settings, we must link the shared library with our own command.
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
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.
We have to provide the MD5ENABLE definition because it is not
provided on this OS.
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/
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/
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
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.
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.
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.
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'.
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.
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.
 |
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.
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)
Enjoy !
Only registered users can write comments. Please login or register. Powered by AkoComment! |