I posted a query on this form about a week ago, asking how to get Java working
with Apache and PHP4. There have been no replies, but there was enough in
the archive to determine (by trial and error) that the following will do it.
Red Hat 6.2 (Linux 2.2.14-5.0 i586)
Apache 1.3.19
PHP 4.0.5
jdk118_v1 (Blackdown port of JDK1.1.8)
In the Apache home directory:
(make clean) -- in case an earlier version is present
./configure -enable-module=so --enable-rule=SHARED_CORE --prefix=/www
make
make install
In the PHP home directory:
(make clean)
./configure --with-apxs=/www/bin/apxs --with-java=/usr/local/jdk118_v1
--with-perl=/usr/bin/perl --with-mysql=/usr/local/mysql
--with-zlib=/usr/lib -enable-track-vars
make
make install
Without the zlib, you get a complaint about "undefined: uncompress"
Edit the php.ini file (usually in /usr/local/lib/php.ini):
extension_dir = /usr/local/src/php-4.0.5/modules
extension = libphp_java.so
In the [Java] section:
java.class.path=/usr/local/jdk118_v1/lib:/usr/local/lib/php_java.jar
This is all it needs! (Without the jdk118_v1/lib, it tries to find net/php/reflect,
and fails; what it really wants is java/lang/reflect from uncompressing
classes.zip. Without the php_java.jar, it can't create the Java Virtual Machine.)
It is somehow smart enough to find the java.library it needs, as revealed by
looking at the output of phpinfo().
With this installation running, I can send output from a running Java object, and
receive the results in PHP. Here is a simple example:
<?
$system = new Java("java.lang.System");
print("Java version: " .
$system->getProperty("java.version") .
"<br>\n");
?>
Pop this little program into your htdocs directory, and point your browser to it,
and you will indeed see the Java version number displayed!
Hope somebody finds this useful.
Curtis Lacy