Adding PHP to solaris-8 bundled apache

Note: This is for the apache that now ships WITH sun solaris 8. It has successfully been tested with php4.1.0, and earlier versions.

Tip: if you want a newer version of apache, with no fuss, then you can use pkg-get to grab pre-compiled versions of everything you need, from OpenCSW.org !

Otherwise, if you really want to do things the hard way, and compile everything yourself, then keep reading...


Compiling PHP and its dependancies

I assume that you want to build PHP with SSL, berkeley "db" support, and oracle support. If you dont, then just remove the appropriate bits from the 'configure' line below.

Oracle note: It is a very odd stupidity that you have to install the ENTIRE oracle database (eg: 'everything') to get the include files you need for the oci8 client libraries. Or at least the ones everyone expects, under $ORACLE_HOME/rdbms/demo.
Oddly, choosing the "developer" option from the installer, isnt enough.

Prerequisite packages: ("SFW" packages are fron Sun's "companion CD")

SUNWapchr
SUNWapchu
SUNWzlib
SFWbdb    [or CSWbdb from opencsw.org, and adjust paths appropriately]
SFWmysql  [If you want extra-good mysql support. Not strictly required for php.]
Check that you have the packages above, by running
pkginfo SUNWapchr SUNWapchu SUNWzlib SFWbdb
If there are any missing, install "SUNW" pacakges from the sol8 CDs, and SFW packages from the "companion (freeware) CD"


Configure and Compiling

Once you have downloaded and extracted the php source directory, you should do some prep work by setting the following environment variable:

export LD_RUN_PATH
LD_RUN_PATH=/usr/local/ssl/lib
#if you are compiling with oracle
LD_RUN_PATH=$LD_RUN_PATH:`dbhome`/lib
#if you are compiling with mysql
LD_RUN_PATH=$LD_RUN_PATH:/opt/sfw/mysql/lib/mysql
This will ensure that apache wont need some long funky LD_LIBRARY_PATH set to run. Adjust the paths as appropriate for your box.

Note for php4.2.1: If you are using gcc to compile, you will have to also do:
export CC; CC=gcc

You can then configure the source build by running the following command:


 ./configure --with-apxs=/usr/apache/bin/apxs \
--with-zlib=/usr --with-db3=/opt/sfw   \
--with-openssl=/usr/local/ssl
  # ( add --with-oci8=`dbhome`  for oracle )
  # ( add "--with-mysql=/opt/sfw/mysql" if you have SFWmysql )
  # ( add "--with-db3=/usr/local" to use SMCdb instead of SFWdb )
IF you want the "ora_xxx" as well as the "oci_xxx" functions, add --with-oracle=`dbhome`

Once you're done with THAT, then ... follow the directions in the php INSTALL file. Pretty much just "make install", and then uncommenting the php4 lines in /etc/apache/httpd.conf

If you add in mysql, you may need to do

# (cd /opt/sfw/mysql/lib/mysql ; ln -s  . .libs)
because libtool is a stupid broken linux-specific piece of $H!7.
Happily, if you have /opt/sfw/mysql/lib/mysql in LD_RUN_PATH, you can remove /opt/sfw/mysql/lib/mysql/.libs after the compile, and you'll be just fine.

httpd.conf changes

The sun "apxs" binary is slightly broken, so after doing a make install, you will have to change

LoadModule php4_module        libexec/libphp4.so
to
LoadModule php4_module        /usr/apache/libexec/libphp4.so

You will also have to uncomment the appropriate AddType line for php in httpd.conf
(AddType application/x-httpd-php .php)

Oracle issues

If you get errors like cannot find library, or oci.h, then you may need to do the following as root:
# cd `dbhome`
# chmod 0755 lib */public */demo

Additionally, if you want to talk to a remote oracle server (as opposed to one running on your web server), you may have to recompile php to use ODBC, from www.iodbc.org, instead of the normal Oracle client libraries. There is even a PHP-specific HOWTO document on the iodbc website.

If the oracle client libraries work for you, use them. Otherwise, try ODBC.

post-compile hackery

If you forgot the LD_RUN_PATH trick above, and you dont want to/cant recompile, you will have to edit /etc/init.d/apache and add the following at the top:
export LD_LIBRARY_PATH
LD_LIBRARY_PATH=/usr/local/ssl/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sfw/mysql/lib/mysql
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib


PHP Tutorial

BTW: the official php tutorial is at http://www.php.net/tut.php


Written by: Philip Brown © 2000,2001
Solaris Top