|
| 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 : |
PL 820 |
| OS : |
AIX 5.2 |
| Date : |
Sep 2006 |
| Shell : |
/usr/bin/ksh |
| User : |
root (not mandatory) |
| Oracle client : |
9.2.0.6 |
1.5 -
Pre-requisite
We also create a link in /usr/local/bin in order to ensure we use GNU make
and not /usr/ccs/bin/make :
ln -s make /usr/local/bin/gmake |
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 :
We set the variables specific to this environment :
export CPPFLAGS="-I $BLIB/z/include -I $BLIB/ssl/include"
export LDFLAGS="-L$BLIB/common -Wl,-brtl"
export blibpath="$BLIB/common:/usr/lib" |
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.a $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/
The OpenSSL package does not provide a method to build shared
libraries with gcc on AIX. As we need one, we enhance the aix-gcc method
in the Configure file :
repl='aix-shared:-fPIC:-shared:.so'
sed "s!^\(.aix-gcc.*dlfcn:\)!\1$repl!" <Configure >tmp1
cp tmp1 Configure
unset repl |
But our workaround is not perfect because we have to copy the shared
libraries manually.
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.
./Configure --openssldir=$BLIB/ssl shared zlib aix-gcc
gmake "SHARED_LDFLAGS = -shared $LDFLAGS" \
"EX_LIBS = $LDFLAGS -ldl -lz" \
"SHAREDFLAGS = $LDFLAGS -Wl,-G,-bE:lib\$\$i.exp"
gmake install_sw
#-- Install AIX shared libraries
cp -p libcrypto.so.0.9.7 $BLIB/ssl/lib/libcrypto.so
cp -p libssl.so.0.9.7 $BLIB/ssl/lib/libssl.so
#-- Cleanup
rm -rf $BLIB/ssl/man $BLIB/ssl/lib/*.a
$LINKDIR ssl/lib
gmake test "EX_LIBS = $LDFLAGS -ldl -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 "CPPFLAGS = $CPPFLAGS -fPIC"
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.
For various reasons, we don't want '/usr/ccs/lib' in the library search
path of the generated executable files. So, we copy the ndbm library to
$BLIB, just for compile time. This library is static, so we can remove it
after it is linked.
cp -p /usr/ccs/lib/libdbm.a $BLIB |
By default, the LDAP modules are not linked against the LDAP library.
So, they cannot be loaded. Workaround: after having compiled everything, we
delete the LDAP modules and recompile them while forcing the LDAP library.
#-- 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
\
--with-dbm=ndbm \
--with-ndbm=/usr/include:$BLIB \
--without-gdbm
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 "LDFLAGS = $LDFLAGS -R $BLIB/common"
#-- Rebuild mod_ldap and mod_auth_ldap
rm mod*/exp*/mod*ldap.la
gmake "LDFLAGS = $LDFLAGS -R $BLIB/common -lldap"
#-- Install
gmake install
chown -Rh root:sys $BAP
/bin/rm $BLIB/libdbm.a #-- Remove static ndbm library
chown -Rh root:sys $BAP |
2.10 - Compiling mod_jk (tomcat-connectors 1.2.18)
Source :
http://tomcat.apache.org/download-connectors.cgi
cd native
./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 |
2.14 - Compiling libjpeg (v6b)
Source : http://www.ijg.org/files
The Makefile does not know how to build a shared library on AIX. We have
to do it manually.
The 'Makefile' install (install-lib target) does not work
on AIX. So, we install it another way.
CPPFLAGS="$CPPFLAGS -fPIC" \
./configure --prefix=$BLIB/jpeg $CF_OPTS
#-- Build library
gmake libjpeg.la
gcc -shared -o libjpeg.so *.o
#-- Manual install
mkdir -p $BLIB/jpeg/include $BLIB/jpeg/lib
cp jconfig.h jpeglib.h jmorecfg.h jerror.h $BLIB/jpeg/include
sed -e "s/\(dlname=\)''/\1'libjpeg.so'/" \
-e "s/\(library_names=\)''/\1'libjpeg.so'/" \
-e "s/\(old_library=\)'.*\$/\1''/" <libjpeg.la
>$BLIB/jpeg/lib/libjpeg.la
cp libjpeg.so $BLIB/jpeg/lib
$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.so.1.0.1
ln -s libbz2.so.1.0.1 $BLIB/bz2/lib/libbz2.so.1.0
ln -s libbz2.so.1.0 $BLIB/bz2/lib/libbz2.so.1
ln -s libbz2.so.1 $BLIB/bz2/lib/libbz2.so
$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 ga4 "MAKE = gmake" "EXTRACFLAGS = -fPIC -DMD5ENABLE=\"\""
\
"EXTRASPECIALS = CC=gcc"
#-- Build the dynamic one
cd c-client
gcc -shared -o libc-client.so *.o $LDFLAGS -lssl -lcrypto -Wl,-G -lz
#-- Install the headers and the library
#-- PHP configure needs a '.a' file
mkdir -p $BLIB/imap/lib $BLIB/imap/include
cp libc-client.so $BLIB/imap/lib
ln -s libc-client.so $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="$LDFLAGS" \
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 "CC=gcc -Wl,-brtl" "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
This one is a nightmare and definitely not for the faint-hearted, mostly because
of the silly way the AIX runtime linker manages shared libraries and objects.
So, the only solution I found after several hours of fighting was to build it in
several steps, feeding the linker with some weird options. But the result works
well...
There is a bug in this version of libtool when generating shared
libraries for AIX. Workaround : we modify the libtool script after the configure
stage.
The 'Makefile' install of the Apache module does not work on AIX
because of a suffix incoherence (.so/.a). Workaround : we install it manually.
Only difference : we will have to add the 'LoadModule' directive manually in
httpd.conf (LoadModule php4_module modules/libphp4.so). If you add it
now, prefix the line with a '#' char because PHP 4 & 5 Apache modules cannot be
active together.
libtool does not install shared extensions as '.so' files, but as '.a'
files. We have to extract the '.so' files by ourselves.
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.
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
./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
#-- Fix libtool
sed 's!\\\$objdir/!\\\$output_objdir/!g' <libtool >tmp1
cp tmp1 libtool
chmod +x libtool
#-- Hungry linker, needs additional '-R' options...
export LDFLAGS="$LDFLAGS -R $BLIB/common"
[ "$ORACLE_HOME" != 'none' ] \
&& export LDFLAGS="$LDFLAGS -R $BLIB/oracle/$_oralibdir"
#-- Build : First step
gmake
#-- 2nd step : Build symbol table
echo "#! ." >php.sym
echo >>php.sym
cat .libs/libphp4.exp >>php.sym
#-- 3rd step : Build Apache module and CLI interpreter with exported symbols
/bin/rm -f libphp4.la .libs/libphp4.so sapi/cli/php
gmake "LDFLAGS = $LDFLAGS -Wl,-bE:$PWD/php.sym,-bexpall"
#-- Restore LDFLAGS
export LDFLAGS="$REF_LDFLAGS"
#-- Install everything except Apache module
gmake install-cli install-modules install-build install-headers \
install-programs install-pear
#-- Install Apache module
/bin/rm -f $BAP/modules/libphp4.so
cp .libs/libphp4.so $BAP/modules
chmod 755 $BAP/modules/libphp4.so
#-- Move extensions (personal, I don't like this 'no-debug...' dir)
cd $PBASE/lib/php/extensions
mv */* .
rmdir no-debug*
cd ~-
#-- Change suffix of extension libraries (.a -> .so)
cd $PBASE/lib/php/extensions
for i in *.a ; do ar xv $i ; done
/bin/rm -f *.a
cd ~-
#-- Install default configuration file
cp php.ini-recommended $PBASE/php.ini |
2.23 - Compiling PHP
5 (5.1.6)
Source : www.php.net
Here, libtool (mode=link) needs an additional '-R' option to put what
we need in the library search paths. An other workaround would be to modify the
generated libtool script, but it is more complex.
Problem with the PDO extension in shared mode (Apache process
crashes after loading this extension). As this problem does not occur when PDO
is compiled in static mode, we use it this way. The problem does not occur with
PDO drivers, which are still compiled in shared mode.
Problem with the GD shared extension (unresolved 'math'
symbols). Bug reported as
#38868. Workaround: we rebuild it alone while forcing the '-lm' link flag.
Ignore this error message from configure : './configure[75167]:
pkg-config: not found.'. It is a configure bug reported as
#35981. This error does not seem to have any influence on the rest of the build
process.
The 'Makefile' install of the Apache module does not work on AIX
because of a suffix incoherence (.so/.a). Workaround : we install it manually.
Only difference : we will have to add the 'LoadModule' directive manually in
httpd.conf (LoadModule php5_module modules/libphp5.so).
A bug was introduced with PHP version 5.1.4: the sed command to generate
the list of global symbols (needed to link the CLI interpreter) is wrong. This
bug is specific to AIX. Bug reported as
#38872.
Workaround : after configure has run, we modify the Makefile to correct the sed
command.
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=''
./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 \
--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
#-- Modify the Makefile to work around bug #38872
sed 's!\\1\.o!.libs\\/\\1.o!' <Makefile >tmp1
cp tmp1 Makefile
export LDFLAGS="$LDFLAGS -R $BLIB/common"
[ "$ORACLE_HOME" != 'none' ] \
&& export LDFLAGS="$LDFLAGS -R $BLIB/oracle/lib32"
gmake
#-- Rebuild gd.so with the '-lm' flag
rm ext/gd/gd.so
gmake LDFLAGS="$LDFLAGS -lm"
export LDFLAGS="$REF_LDFLAGS"
#-- Install everything except Apache module
gmake install-cli install-modules install-build install-headers \
install-programs install-pear
#-- Install Apache module
/bin/rm -f $BAP/modules/libphp5.so
cp .libs/libphp5.so $BAP/modules
chmod 755 $BAP/modules/libphp5.so
#-- 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 |
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 LANG
unset LIBPATH SHLIB_PATH LD_LIBRARY_PATH
cd $BASE
for i in `find . -type f`; do
file $i | grep executable >/dev/null || continue
echo $i
done | while read f
do
ldd $f
done 2>&1 | fgrep -v 'needs:' \
| tr '[:space:]' ' ' \
| sed -e 's!(.*$!!' -e 's!^ !!g' -e 's!\.a$!!' \
| sort -u \
| grep -v libodm \
| grep -v '^/unix$' \
| grep -v "^$BASE/" |
This script is quite long to execute (up to 3 min). The results must show only the following system libraries :
- /usr/lib/libc
- /usr/lib/libcrypt
- /usr/lib/libdl
- /usr/lib/libnsl
- /usr/lib/libpthread
- /usr/lib/libpthreads
- /usr/lib/libpthreads_compat
- /usr/lib/librtl
- /usr/lib/libs
- /usr/lib/libtli
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. You can now 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)
- If you want Apache to start
and stop automaticaly at bootup/shutdown time, create the corresponding
entries in the system files (see above)
- Configure Apache ($BAP/conf) and PHP ($BASE/php{4,5}/php.ini)
- Start Apache with : <$BASE>/system/apache
start
- Check the PHP modules (see above)
Enjoy !
Only registered users can write comments. Please login or register. Powered by AkoComment! |