Talk:How to set up PHP under AOLserver

From AOLserver Wiki
Jump to navigation Jump to search

I cannot get php-5.1.1 to build with Debian 3.1 package of aolserver4 and aolserver4-dev (which is built with --prefix=/usr/lib/aolserver4):

sam@caveman:~/downloads/$ ./configure --with-aolserver=/usr/lib/aolserver4
loading cache ./config.cache

Configuring SAPI modules
checking for AOLserver support... /usr/lib/aolserver4
configure: error: Please specify the path to the source distribution of AOLserver using --with-aolserver-src=DIR
  • I only ever tested this against PHP 4.3.7 -- I don't know what is required to make it work with PHP 5.1.1. If you figure it out, please update the page. -- Dossy 12:05, 7 December 2005 (EST)
    • I opened a PHP bug issue for this: [1] --Caveman 14:05, 8 December 2005 (EST)
      • This may be an issue more with the way Debian 3.1 installs AOLserver 4 than anything else. The "proper" PHP configure command should be:
./configure --with-aolserver=/path/to/installed/aolserver

Debian 3.1 configures AOLServer with a prefix of "/usr/lib/aolserver4". However, using this as the "/path/to/installed/aolserver" results in the same error and a request for "--with-aolserver-src".

        • I configured and installed aolserver4 from source into "/home/sam/aolserver". PHP configure finally completed successfully. However, PHP compile still failed:
/bin/sh /home/sam/downloads/ --silent --preserve-dup-deps --mode=compile /home/sam/downloads/  -Isapi/aolserver/ -I/home/sam/downloads/ -DPHP_ATOM_INC -I/home/sam/downloads/ -I/home/sam/downloads/ -I/home/sam/downloads/ -I/home/sam/aolserver/include -I/usr/include/libxml2 -I/home/sam/downloads/ -I/home/sam/downloads/ -I/home/sam/downloads/  -D_REENTRANT  -g -O2 -pthread -DZTS  -prefer-non-pic -c /home/sam/downloads/ -o sapi/aolserver/aolserver.lo
In file included from /home/sam/aolserver/include/ns.h:62,
                 from /home/sam/downloads/
/home/sam/aolserver/include/nsthread.h:125:17: tcl.h: No such file or directory

This was obviously an error finding "tcl.h". I manually edited the PHP "Makefile" and set:

EXTRA_INCLUDES = -I/usr/include/tcl8.4

This allowed PHP compilation to complete. The module loaded successfully and PHP scripts work as expected (see phpinfo output). --Caveman 19:05, 8 December 2005 (EST)

With trial and error, I was able to configure and compile against the Debian 3.1 packages as installed by default:

./configure --with-aolserver=/usr
make "EXTRA_INCLUDES=-I/usr/include/tcl8.4 -I/usr/include/aolserver4"

I was able to get php 5.1.2 to make with the above (after satisfying all the dependencies, first), no patching necessary. --mcginniwa 8 April 2006

extending PHP to take advantage of AOLServer

proposal: write a PHP extension to provide PHP functions to access AOLserver database pools (and perhaps other important features like shared memory).

In other words, provide PHP functions:


And so on. It should be nearly trivial to do this, and give PHP on AOLserver a very powerful advantage over PHP on Apache.

Extending PHP By Sterling Hughes

sam@caveman:~/downloads/$ ./ext_skel --extname=nsdb
Creating directory nsdb
Creating basic files: config.m4 config.w32 .cvsignore nsdb.c php_nsdb.h CREDITS EXPERIMENTAL tests/001.phpt nsdb.php [done].

To use your new extension, you will have to execute the following steps:

1.  $ cd ..
2.  $ vi ext/nsdb/config.m4
3.  $ ./buildconf
4.  $ ./configure --[with|enable]-nsdb
5.  $ make
6.  $ ./php -f ext/nsdb/nsdb.php
7.  $ vi ext/nsdb/nsdb.c
8.  $ make

Repeat steps 3-6 until you are satisfied with ext/nsdb/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary.

Getting PHP and AOLserver to work on Mac OS X

The hacks to get PHP and AOLserver dont work on the Mac due to its "interesting" linking requirements. It took me several days of headscratching and worse to get everything linked and working.

Here are some things you want to be aware of if you intend to do this.

  • If you "accidently" put AOLserver in /usr or /usr/local and then decide to install it elsewhere, you must remove any dylibs that get installed in /usr/lib or /usr/local/lib. The link steps will try those locations and pick up any obsolete builds rather than your new builds.
  • Look closely at the config.m4 scripts in "sapi/apache." for PHP4 or PHP5. They do link on the Mac: They have the secret sauce.
  • use the attached shell script to install PHP4 or PHP5 on AOLserver (or naviserver). Yes, I did test it with all 4 combinations on my system. Will it work on your system? I never guarantee anything. Not even death or taxes.
  • The script depends on the buildconf being present. It also depends on the PHP4 or PHP5 directory structure.
  • if your are doing this for naviserver, you will need to get the optional sapi/naviserver directory from the naviserver guys.
  • make sure you edit the lines that
    • select the destination and source directories for aolserver or naviserver
    • select the version of php (php4 or php5)
    • set the c source file name (nsphp.c for naviserver or aolserver.c for AOLserver)
  • pre-build any ancillary php support (ming, mysql, etc) and put in the BUILDDEST
  • execute the script in the php source top level directory (where you normally would run ./configure)
# build php4 or php5 to run under naviserver or aolserver on OX X

# set bash to super caffeinated mode for lots of talky-talky debug stuff
#set -v
#set -x

#server is naviserver or aolserver -- this script (mostly) works for either: note that the only file that needs to be "fixed"
#is the sapi/server/config.m4
#  We do that here and really ONLY for MAC OSX -- My interests are quite limited.  Be advised.

#this is where your pre-built libs for mysql, ming, etc are hanging out:  They will need include and lib directories under BUILDDEST

#this is where your server will be when you run it.
serverLOWC=`echo $server| tr [:upper:] [:lower:]`
serverCAPS=`echo $server| tr [:lower:] [:upper:]`

OTHERSCONFIG="--with-mysql=$BUILDDEST --with-zlib=/usr --with-ming=$BUILDDEST --with-gd=$BUILDDEST --with-gdm=$BUILDDEST --with-pcre=$BUILDDEST --with-pdf=$BUILDDEST --with-ming=$BUILDDEST"

#phpversion is php4 or php5

cat >sapi/$serverLOWC/config.m4  <<ENDCONFIG
dnl \$Id: config.m4,v 1.15 2002/03/07 14:19:47 sas Exp $

AC_MSG_CHECKING(for $server support)
[  --with-$serverLOWC=DIR    Specify path to the installed ${serverCAPS}],[

if test "\$PHP_${serverCAPS}" != "no"; then
  if test -d "\$PHP_${serverCAPS}/include"; then
  if test -z "\$PHP_${serverCAPS}_SRC" || test ! -d \$PHP_${serverCAPS}_SRC/include; then
    AC_MSG_ERROR(Please specify the path to the source distribution of ${server} using --with-${serverLOWC}-src=DIR)
  if test ! -d \$PHP_${serverCAPS}/bin ; then
    AC_MSG_ERROR(Please specify the path to the root of ${server} using --with-${serverLOWC}=DIR)
  AC_DEFINE(WITH_${serverCAPS},1,[Whether you want ${server} support])
  AC_DEFINE(HAVE_${serverCAPS},1,[Whether you have ${server}])
  case \$host_alias in
    MH_BUNDLE_FLAGS="-dynamic -twolevel_namespace -bundle -bundle_loader \\\$(INSTALL_ROOT)\$PHP_${serverCAPS}/bin/nsd"
	PHP_FRAMEWORKS="-framework Tcl -framework CoreFoundation"
	EXTRA_LIBS="\$EXTRA_LIBS -L\$PHP_${serverCAPS}/lib -lnsd -lnsthread"

  PHP_SELECT_SAPI($serverLOWC, \$build_type, $c_source)
  INSTALL_IT="\\\$(INSTALL) -m 0755 \$SAPI_SHARED \\\$(INSTALL_ROOT)\$PHP_${serverCAPS}/bin/"

dnl ## Local Variables:
dnl ## tab-width: 4
dnl ## End:


rm -f autom4te.cache/*
./buildconf --force
make clean
./configure --with-$serverLOWC=$DEST  --prefix=$BUILDDEST $OTHERSCONFIG
cp libs/lib${phpkind}.so $DEST/bin