Difference between revisions of "Talk:How to set up PHP under AOLserver"

From AOLserver Wiki
Jump to navigation Jump to search
(Getting PHP and AOLserver to work on Mac OS X)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
I've downloaded the aolserver src both directly and via the Debian source package, but cannot get php-5.1.1 to build:
+
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):
  
 
<pre>
 
<pre>
sam@caveman:~/downloads/php.net/php-5.1.1$ ./configure --with-aolserver --with-aolserver-src=/home/sam/downloads/aolserver.org/aolserver-4.0.10
+
sam@caveman:~/downloads/php.net/php-5.1.1$ ./configure --with-aolserver=/usr/lib/aolserver4
aolserver-4.0.10            aolserver-4.0.10-src.tar.gz
 
sam@caveman:~/downloads/php.net/php-5.1.1$ ./configure --with-aolserver --with-aolserver-src=/home/sam/downloads/aolserver.org/aolserver-4.0.10 --enable-shared
 
 
loading cache ./config.cache
 
loading cache ./config.cache
checking for Cygwin environment... no
+
...
checking for mingw32 environment... no
+
...
checking for egrep... grep -E
 
checking for a sed that does not truncate output... /bin/sed
 
checking host system type... i686-pc-linux-gnu
 
checking target system type... i686-pc-linux-gnu
 
checking for gcc... gcc
 
checking whether the C compiler (gcc  ) works... yes
 
checking whether the C compiler (gcc  ) is a cross-compiler... no
 
checking whether we are using GNU C... yes
 
checking whether gcc accepts -g... yes
 
checking whether gcc and cc understand -c and -o together... yes
 
checking how to run the C preprocessor... gcc -E
 
checking for AIX... no
 
checking whether ln -s works... yes
 
checking if compiler supports -R... no
 
checking if compiler supports -Wl,-rpath,... yes
 
checking for re2c... re2c
 
checking for re2c version... invalid
 
configure: warning: You will need re2c 0.98 or later if you want to regenerate PHP parsers.
 
checking for gawk... gawk
 
checking for bison... bison -y
 
checking for bison version... 1.875 (ok)
 
checking for flex... flex
 
checking for yywrap in -lfl... yes
 
checking lex output file root... lex.yy
 
checking whether yytext is a pointer... yes
 
checking for working const... yes
 
checking for flex version... invalid
 
configure: warning: flex versions supported for regeneration of the Zend/PHP parsers: 2.5.4  (found: 2.5.31).
 
checking whether to force non-PIC code in shared modules... yes
 
checking for pthreads_cflags... -pthread
 
checking for pthreads_lib...
 
  
 
Configuring SAPI modules
 
Configuring SAPI modules
checking for AOLserver support... yes
+
checking for AOLserver support... /usr/lib/aolserver4
 
configure: error: Please specify the path to the source distribution of AOLserver using --with-aolserver-src=DIR
 
configure: error: Please specify the path to the source distribution of AOLserver using --with-aolserver-src=DIR
 
sam@caveman:~/downloads/php.net/php-5.1.1$
 
sam@caveman:~/downloads/php.net/php-5.1.1$
 
</pre>
 
</pre>
 
<pre>
 
sam@caveman:~/downloads/php.net/php-5.1.1$ ls /home/sam/downloads/aolserver.org/aolserver-4.0.10
 
ChangeLog  configure    index.html    nscgi  nsext  nssock            tcl
 
Makefile    configure.in  ini2tcl.tcl    nscp  nslog  nsssl              tcl2ini.tcl
 
README      doc          install-sh    nsd    nspd    nsthread          tests
 
aclocal.m4  include      license.terms  nsdb  nsperm  sample-config.tcl  win32
 
sam@caveman:~/downloads/php.net/php-5.1.1$
 
</pre>
 
 
Perhaps I am simply an idiot (would not be the first time) but something "no longer works".
 
  
 
* ''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.  -- [[User:Dossy|Dossy]] 12:05, 7 December 2005 (EST)''
 
* ''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.  -- [[User:Dossy|Dossy]] 12:05, 7 December 2005 (EST)''
Line 61: Line 17:
 
** I opened a PHP bug issue for this: [http://bugs.php.net/bug.php?id=35605] --[[User:Caveman|Caveman]] 14:05, 8 December 2005 (EST)
 
** I opened a PHP bug issue for this: [http://bugs.php.net/bug.php?id=35605] --[[User:Caveman|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:
+
*** 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:
 
<pre>
 
<pre>
 
./configure --with-aolserver=/path/to/installed/aolserver
 
./configure --with-aolserver=/path/to/installed/aolserver
Line 75: Line 31:
 
                 from /home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:49:
 
                 from /home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:49:
 
/home/sam/aolserver/include/nsthread.h:125:17: tcl.h: No such file or directory
 
/home/sam/aolserver/include/nsthread.h:125:17: tcl.h: No such file or directory
In file included from /home/sam/aolserver/include/ns.h:62,
 
                from /home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:49:
 
/home/sam/aolserver/include/nsthread.h:178: error: syntax error before '*' token
 
/home/sam/aolserver/include/nsthread.h:215: error: syntax error before '*' token
 
/home/sam/aolserver/include/nsthread.h:294: error: syntax error before '*' token
 
In file included from /home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:49:
 
/home/sam/aolserver/include/ns.h:275: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:276: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:277: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:284: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:287: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:442: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:446: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:455: error: syntax error before "Ns_CacheSearch"
 
/home/sam/aolserver/include/ns.h:455: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:507: error: syntax error before "Ns_CacheSearch"
 
/home/sam/aolserver/include/ns.h:508: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:545: error: syntax error before "Tcl_DString"
 
/home/sam/aolserver/include/ns.h:546: error: syntax error before "Tcl_DString"
 
/home/sam/aolserver/include/ns.h:571: error: syntax error before "Tcl_DString"
 
/home/sam/aolserver/include/ns.h:575: error: syntax error before "Tcl_DString"
 
/home/sam/aolserver/include/ns.h:576: error: syntax error before "Tcl_Channel"
 
/home/sam/aolserver/include/ns.h:580: error: syntax error before "Tcl_DString"
 
/home/sam/aolserver/include/ns.h:581: error: syntax error before "Tcl_Channel"
 
/home/sam/aolserver/include/ns.h:585: error: syntax error before "Tcl_Encoding"
 
/home/sam/aolserver/include/ns.h:586: error: syntax error before "Ns_ConnGetEncoding"
 
/home/sam/aolserver/include/ns.h:586: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:587: error: syntax error before "Tcl_Encoding"
 
/home/sam/aolserver/include/ns.h:588: error: syntax error before "Ns_ConnGetUrlEncoding"
 
/home/sam/aolserver/include/ns.h:588: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:617: error: syntax error before "Tcl_Encoding"
 
/home/sam/aolserver/include/ns.h:629: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:630: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:631: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:643: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:644: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:645: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:646: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:647: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:648: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:649: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:649: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:650: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:672: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:764: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:765: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:771: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:772: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:778: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:780: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:782: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:784: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:850: error: syntax error before "Ns_GetEncoding"
 
/home/sam/aolserver/include/ns.h:850: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:851: error: syntax error before "Ns_GetFileEncoding"
 
/home/sam/aolserver/include/ns.h:851: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:852: error: syntax error before "Ns_GetTypeEncoding"
 
/home/sam/aolserver/include/ns.h:852: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:853: error: syntax error before "Ns_GetCharsetEncoding"
 
/home/sam/aolserver/include/ns.h:853: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:892: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:893: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:894: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:895: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:896: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:904: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:916: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:932: error: syntax error before "Tcl_DString"
 
/home/sam/aolserver/include/ns.h:966: error: syntax error before "Tcl_Channel"
 
/home/sam/aolserver/include/ns.h:1095: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1102: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1104: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1111: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1112: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1115: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1116: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1117: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1117: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:1118: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1119: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1119: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:1120: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1122: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1123: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1133: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1134: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1135: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1136: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1136: warning: data definition has no type or storage class
 
/home/sam/aolserver/include/ns.h:1143: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1144: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1145: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1146: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1152: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1162: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1168: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1170: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1172: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1174: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1181: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1182: error: syntax error before '*' token
 
/home/sam/aolserver/include/ns.h:1221: error: syntax error before '*' token
 
/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c: In function `php_ns_request_ctor':
 
/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:428: error: `Tcl_DString' undeclared (first use in this function)
 
/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:428: error: (Each undeclared identifier is reported only once
 
/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:428: error: for each function it appears in.)
 
/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:428: error: syntax error before "ds"
 
/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:438: error: `ds' undeclared (first use in this function)
 
/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:442: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
 
/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:442: warning: passing arg 2 of `memcpy' makes pointer from integer without a cast
 
/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:442: warning: passing arg 1 of `__strdup' makes pointer from integer without a cast
 
make: *** [sapi/aolserver/aolserver.lo] Error 1
 
 
</pre>
 
</pre>
  
Line 204: Line 48:
 
make "EXTRA_INCLUDES=-I/usr/include/tcl8.4 -I/usr/include/aolserver4"
 
make "EXTRA_INCLUDES=-I/usr/include/tcl8.4 -I/usr/include/aolserver4"
 
</pre>
 
</pre>
 +
 +
----
 +
 +
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 ==
 
== extending PHP to take advantage of AOLServer ==
Line 209: Line 58:
 
http://aolserver.org/docs/devel/c/api/c-ch3.htm#37064
 
http://aolserver.org/docs/devel/c/api/c-ch3.htm#37064
  
proposal: write a PHP extension to provide PHP functions to access AOLServer database pools (and perhaps other important features like shared memory).
+
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:
 
In other words, provide PHP functions:
Line 218: Line 67:
 
</pre>
 
</pre>
  
And so on. It should be nearly trivial to do this, and give PHP on AOLServer a very powerful advantage over PHP on Apache.
+
And so on. It should be nearly trivial to do this, and give PHP on AOLserver a very powerful advantage over PHP on Apache.
 +
 
 +
[http://www.webtechniques.com/archives/2001/01/junk/ Extending PHP By Sterling Hughes]
 +
 
 +
<pre>
 +
sam@caveman:~/downloads/php.net/php-5.1.1/ext$ ./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.
 +
</pre>
 +
 
 +
== 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)
 +
 
 +
<pre>
 +
# 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.
 +
#server=Naviserver
 +
#c_source=nsphp.c
 +
server=AOLserver
 +
c_source=aolserver.c
 +
 
 +
#this is where your pre-built libs for mysql, ming, etc are hanging out:  They will need include and lib directories under BUILDDEST
 +
BUILDDEST=$HOME/development/builds
 +
 
 +
#this is where your server will be when you run it.
 +
DEST=$HOME/$server
 +
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
 +
phpkind=php4
 +
 
 +
cat >sapi/$serverLOWC/config.m4  <<ENDCONFIG
 +
dnl
 +
dnl \$Id: config.m4,v 1.15 2002/03/07 14:19:47 sas Exp $
 +
dnl
 +
 
 +
RESULT=no
 +
AC_MSG_CHECKING(for $server support)
 +
AC_ARG_WITH($serverLOWC,
 +
[  --with-$serverLOWC=DIR    Specify path to the installed ${serverCAPS}],[
 +
  PHP_$serverCAPS=\$withval
 +
],[
 +
  PHP_$serverCAPS=no
 +
])
 +
AC_MSG_RESULT(\$PHP_${serverCAPS})
 +
 
 +
if test "\$PHP_${serverCAPS}" != "no"; then
 +
  if test -d "\$PHP_${serverCAPS}/include"; then
 +
    PHP_${serverCAPS}_SRC=\$PHP_${serverCAPS}
 +
  fi
 +
  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)
 +
  fi
 +
  if test ! -d \$PHP_${serverCAPS}/bin ; then
 +
    AC_MSG_ERROR(Please specify the path to the root of ${server} using --with-${serverLOWC}=DIR)
 +
  fi
 +
  PHP_BUILD_THREAD_SAFE
 +
  AC_DEFINE(WITH_${serverCAPS},1,[Whether you want ${server} support])
 +
  AC_DEFINE(HAVE_${serverCAPS},1,[Whether you have ${server}])
 +
  PHP_ADD_INCLUDE(\$PHP_${serverCAPS}_SRC/include)
 +
  case \$host_alias in
 +
  *darwin*)
 +
    MH_BUNDLE_FLAGS="-dynamic -twolevel_namespace -bundle -bundle_loader \\\$(INSTALL_ROOT)\$PHP_${serverCAPS}/bin/nsd"
 +
    PHP_SUBST(MH_BUNDLE_FLAGS)
 +
PHP_FRAMEWORKS="-framework Tcl -framework CoreFoundation"
 +
EXTRA_LIBS="\$EXTRA_LIBS -L\$PHP_${serverCAPS}/lib -lnsd -lnsthread"
 +
    SAPI_SHARED=libs/lib${phpkind}.so
 +
    build_type=bundle
 +
    ;;
 +
  *)
 +
    build_type=shared
 +
    ;;
 +
  esac
 +
 
 +
 
 +
  PHP_SELECT_SAPI($serverLOWC, \$build_type, $c_source)
 +
  INSTALL_IT="\\\$(INSTALL) -m 0755 \$SAPI_SHARED \\\$(INSTALL_ROOT)\$PHP_${serverCAPS}/bin/"
 +
fi
 +
 
 +
dnl ## Local Variables:
 +
dnl ## tab-width: 4
 +
dnl ## End:
 +
 
 +
ENDCONFIG
 +
 
 +
 
 +
 
 +
rm -f autom4te.cache/*
 +
./buildconf --force
 +
make clean
 +
./configure --with-$serverLOWC=$DEST  --prefix=$BUILDDEST $OTHERSCONFIG
 +
make
 +
cp libs/lib${phpkind}.so $DEST/bin
 +
 
 +
</pre>

Latest revision as of 17:43, 17 October 2006

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/php.net/php-5.1.1$ ./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
sam@caveman:~/downloads/php.net/php-5.1.1$
  • 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/php.net/php-5.1.1/libtool --silent --preserve-dup-deps --mode=compile /home/sam/downloads/php.net/php-5.1.1/meta_ccld  -Isapi/aolserver/ -I/home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/ -DPHP_ATOM_INC -I/home/sam/downloads/php.net/php-5.1.1/include -I/home/sam/downloads/php.net/php-5.1.1/main -I/home/sam/downloads/php.net/php-5.1.1 -I/home/sam/aolserver/include -I/usr/include/libxml2 -I/home/sam/downloads/php.net/php-5.1.1/ext/date/lib -I/home/sam/downloads/php.net/php-5.1.1/TSRM -I/home/sam/downloads/php.net/php-5.1.1/Zend  -D_REENTRANT  -g -O2 -pthread -DZTS  -prefer-non-pic -c /home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c -o sapi/aolserver/aolserver.lo
In file included from /home/sam/aolserver/include/ns.h:62,
                 from /home/sam/downloads/php.net/php-5.1.1/sapi/aolserver/aolserver.c:49:
/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

http://aolserver.org/docs/devel/c/api/c-ch3.htm#37064

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:

ns_db_gethandle
ns_db_select

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/php.net/php-5.1.1/ext$ ./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.
#server=Naviserver
#c_source=nsphp.c
server=AOLserver
c_source=aolserver.c

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

#this is where your server will be when you run it.
DEST=$HOME/$server
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
phpkind=php4

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

RESULT=no
AC_MSG_CHECKING(for $server support)
AC_ARG_WITH($serverLOWC,
[  --with-$serverLOWC=DIR    Specify path to the installed ${serverCAPS}],[
  PHP_$serverCAPS=\$withval
],[
  PHP_$serverCAPS=no
])
AC_MSG_RESULT(\$PHP_${serverCAPS})

if test "\$PHP_${serverCAPS}" != "no"; then
  if test -d "\$PHP_${serverCAPS}/include"; then
    PHP_${serverCAPS}_SRC=\$PHP_${serverCAPS}
  fi
  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)
  fi
  if test ! -d \$PHP_${serverCAPS}/bin ; then
    AC_MSG_ERROR(Please specify the path to the root of ${server} using --with-${serverLOWC}=DIR)
  fi
  PHP_BUILD_THREAD_SAFE
  AC_DEFINE(WITH_${serverCAPS},1,[Whether you want ${server} support])
  AC_DEFINE(HAVE_${serverCAPS},1,[Whether you have ${server}])
  PHP_ADD_INCLUDE(\$PHP_${serverCAPS}_SRC/include)
  case \$host_alias in
  *darwin*)
    MH_BUNDLE_FLAGS="-dynamic -twolevel_namespace -bundle -bundle_loader \\\$(INSTALL_ROOT)\$PHP_${serverCAPS}/bin/nsd"
    PHP_SUBST(MH_BUNDLE_FLAGS)
	PHP_FRAMEWORKS="-framework Tcl -framework CoreFoundation"
	EXTRA_LIBS="\$EXTRA_LIBS -L\$PHP_${serverCAPS}/lib -lnsd -lnsthread"
    SAPI_SHARED=libs/lib${phpkind}.so
    build_type=bundle
    ;;
  *)
    build_type=shared
    ;;
  esac


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

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

ENDCONFIG



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