Home arrow Building software arrow Apache & PHP arrow Building Apache & PHP on Solaris 9

Building Apache & PHP on Solaris 9 Print E-mail
User Rating: / 7
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.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 : V 490
OS : Solaris 9 (64 bit, Generic_118558-06)
Date : Sep 2006
Shell : /bin/ksh
User : root (not mandatory)
Oracle client : 9.2.0

1.5 - Pre-requisite

Product Version Source
gcc 4.1.1 http://www.sunfreeware.com
Libiconv 1.8
GNU make 3.80

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 :

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,-R,$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.so* $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.

./Configure --openssldir=$BLIB/ssl shared zlib solaris-sparcv9-gcc

gmake "SHARED_LDFLAGS = -shared $LDFLAGS" \
    "EX_LIBS = $LDFLAGS -lsocket -lnsl -ldl -lz"

gmake install_sw

#-- Cleanup

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

gmake test "EX_LIBS = $LDFLAGS -lsocket -lnsl -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
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.

#-- 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

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

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 '-R' (the corresponding option for this system) :

for i in libpng-config libpng12-config
    do
    sed -e 's/-Wl,-rpath/-Wl,-R/' <$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

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

gmake
gmake install
/bin/rm -rf $BLIB/jpeg/bin $BLIB/jpeg/man

$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.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

: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 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 gso "MAKE = gmake" "EXTRACFLAGS = -fPIC" \
    "EXTRASPECIALS = CC=gcc"

#-- Build the dynamic one

cd c-client
gcc  -shared -o libc-client.so *.o $LDFLAGS -lssl -lcrypto -lsocket -lnsl -ldl -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/

: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

:note Due to bug #14862, the configure process does not detect that Solaris does not provide the isinf() function (because of GCC 4.x). And, then, the compile stage fails when linking the library. Workaround : we modify the config.h file after the configure stage. This bug is supposed to be corrected in MySQL 5.1.12.

:note We have to temporarily set LD_LIBRARY_PATH because, if it is not set, the compile process does not find the libstdc++ library it needs when regenerating its hash table.

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

#-- Correct the wrong detection of isinf() by configure

grep -v ISINF <config.h >tmp1
cp tmp1 config.h

LD_LIBRARY_PATH='/usr/local/lib' 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/

: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.

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

#-- 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

#-- 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

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=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

#-- 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

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!\.so\.[0-9]$!!' \
    | sort -u \
    | grep -v "^$BASE/" \
    | grep -v '^/usr/lib/libsched$' \
    | grep -v '/libwtc9.so$' \
    | grep -v '/usr/platform'

This script must display only the following system libraries :

  • /usr/lib/libaio
  • /usr/lib/libc
  • /usr/lib/libcmd
  • /usr/lib/libcrypt_i
  • /usr/lib/libdl
  • /usr/lib/libgen
  • /usr/lib/libm
  • /usr/lib/libmd5
  • /usr/lib/libmp
  • /usr/lib/libnsl
  • /usr/lib/libpam
  • /usr/lib/libpthread
  • /usr/lib/libresolv
  • /usr/lib/librt
  • /usr/lib/libsendfile
  • /usr/lib/libsocket
  • /usr/lib/libthread

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 the 3 start/stop symbolic links listed above

ln -s <$BASE>/system/apache /etc/init.d/apache
ln -s ../init.d/apache /etc/rc2.d/K16apache
ln -s ../init.d/apache /etc/rc3.d/S50apache

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

Comments
Written by Ted Fines on 2006-12-09 21:29:21 IP: 141.140.1.111
Great instructions, thanks. Here are a couple notes: 
PHP 4.4.4 would not build with Curl 7.16.0. I backgraded to Curl 7.14.0 and it built fine. 
PHP 4.4.4 also would not build with IMAP-2006c1. I backgraded to IMAP-2004g and it built fine. 
libjpeg6b did not create any of its directories. I did these commands between 'gmake' and 'gmake install' and it then installed fine. If I didn't do these, I'd get 'directory not found' errors when running 'gmake install'. 
mkdir -p $BLIB/jpeg/include 
mkdir $BLIB/jpeg/lib 
mkdir $BLIB/jpeg/bin 
mkdir -p $BLIB/jpeg/man/man1 
 
I used GCC 3.3.2, and it worked fine. 
Written by vidya narayan on 2007-07-03 15:17:22 IP: 207.123.131.49
We are trying to use PHP4.4.2 with Sun solaris 9 (sparc). Do you think there are any major issues with PHP 4.4.2 and Solaris 9. Also there are suggestions the it is better to go with Solaris 10 . Can anybody help me here? 
Thank you.
Written by Peter S. on 2007-11-29 18:44:09 IP: 74.106.138.210
Hi, 
 
This is a great article. Very helpful. 
 
Thanks!
Excellent work.. need some clarification
Written by Shripad Samant on 2007-12-08 00:19:37 IP: 82.240.16.115
Excellent work here..!! 
 
We are trying tp upgrade our system to Solaris 10,Apache 2.2.6 and PHP 5.2.5 !! 
 
I have already got the everything working.. the only part that worries me are those dependencies like SSL and CURL and stuff.. I saw that most of the dependencies are covered here! Only question is: is it necessary to install the dependencies before configuring PHP or can they be installed when we want those modules to be used... can you please let me know..!!! 
 
Re: Yes, you need all these libraries to be present when you run the 'configure' script, as it will look for them, and fail if one of them cannot be found. You will also need them at compile time, when the corresponding extensions are linked, even if they are configured as shared (dynamic) extensions.

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