304 lines (216 with data), 10.1 kB
This file contains very detailed installation instructions. For most
users the build section in the ABOUT.HTM or README and the install.sh
script should be sufficient.
NOTE for Fedora and RedHat Enterprise Linux: Linux RPMs contain
Security Enhanced Linux contexts. If you want to install software on a
SEL system (RHEL, Fedora, ...), please use the RPM build system
instead (rpmbuild --rebuild php-java-bridge*src.rpm). However, for a
development system you can switch off SEL and follow the instructions
below.
Quick Installation from source code
-----------------------------------
mkdir dist
INST=`pwd`/dist
LD_LIBRARY_PATH=$INST/lib:$LD_LIBRARY_PATH
PATH=$INST/bin:$PATH
export INST LD_LIBRARY_PATH PATH
# compile
(cd autoconf-2.59; ./configure --prefix=$INST && make && make install)
(cd automake-1.9; ./configure --prefix=$INST && make && make install)
(cd libtool-1.5.20; ./configure --prefix=$INST && make && make install)
(cd php-5.*; ./configure --prefix=$INST --disable-all --enable-fastcgi && make && make install)
(cd php-java-bridge-3.*; phpize && ./configure --with-java=/usr/java/jdk1.5.0 && make && make install)
# test
php php-java-bridge-3.*/test.php >result.html
Installation from source code (Solaris, FreeBSD, WinXP or Linux)
----------------------------------------------------------------
The following software components must be installed on your computer:
* an operating system. For example RedHat Enterprise Linux. If you
build on Solaris, FreeBSD/MacOSX or WinXP, you also need the GNU
toolchain (gcc, gnu make, autoconf etc.).
* a Java VM. For example IBM JDK 1.4.2 or GNU Java version 3 or above.
* optional: Oracle 9i/10g AS or IBM WebSphere 5/6.
The following instructions build the components:
* the apache web-server
* PHP as a apache module
* the PHP/Java Bridge as a PHP module and/or as a J2EE
component (plugin) for IBM WebSphere or Oracle AS.
and optionally, if you want to run JSP and PHP from Apache/Tomcat:
* mod_jk with Apache/Tomcat.
The following build process first creates an artificial environment
(PATH, LD_LIBRARY_PATH) and installs all components into INST
(default: /usr/local). In a second step the installed components must
be deployed, which usually means that the files must be copied or
moved from the INST (default: /usr/local/) hierarchy into the system
(usually: /usr) hierarchy.
# adjust the install directory
INST=/usr/local #INST=$HOME/bridge
# remove all old files under $INST
#rm -rf $INST
# set build path
export PATH=$INST/bin:$PATH
export LD_LIBRARY_PATH=$INST/lib:$LD_LIBRARY_PATH
# stop the system http service
su - -c "service httpd stop"
# adjust the java version
JAVA_HOME=/opt/jdk1.4.2
#JRE_HOME=/opt/jre1.6.0 # enable this, if you want to hard-code the JRE path
# The following software components are required during the build
# process: autoconf 2.57, automake 1.6.3 and libtool 1.4.3. If you
# don't have autoconf >= 2.57, automake >= 1.6.3 libtool >= 1.4.3, or
# versions which do not match, for example autoconf 2.59 and libtool
# 1.4.3, you must REMOVE THE OLD VERSIONS and compile and install
# these before proceeding:
(cd autoconf-2.57; ./configure --prefix=$INST && make && su -c "make install")
(cd automake-1.6.3; ./configure --prefix=$INST && make && su -c "make install")
(cd libtool-1.4.3; ./configure --prefix=$INST && make && su -c "make install")
#
# BUILD APACHE
# adjust apache MPM. Prefork is standard behaviour in apache 1.3, worker
# creates worker thread pools which deliver content much faster. But note:
# some third-party PHP modules may not be thread-safe.
#
MPM=prefork #MPM=worker
# compile and install apache 2
gunzip < httpd-2.x.y.tar.gz | tar xf -
cd httpd-2.x.y
./configure --with-mpm=$MPM --enable-module=so --prefix=$INST
make && su -c "make install"
cd ..
#
# BUILD PHP
#
bunzip2 < php-x.y.z.tar.bz2 | tar xf -
cd php-x.y.z
./configure --prefix=$INST --disable-all --with-apxs2=$INST/bin/apxs
make && su -c "make install"
# now activate php in the httpd.conf
su -c "echo 'AddType application/x-httpd-php .php' >>$INST/conf/httpd.conf"
cd ..
#
# BUILD THE PHP/JAVA BRIDGE
#
bunzip2 < php-java-bridge_p.x.y.tar.bz2 | tar xf -
cd php-java-bridge-p.x.y
phpize
./configure --with-java=$JAVA_HOME,$JRE_HOME
make && su -c "make install"
# now activate the bridge in php.ini
su -c "touch $INST/lib/php.ini && echo -e 'extension=java.so\n[java]' >>$INST/lib/php.ini"
cd ..
# TEST
# create a file phpinfo.php in the document root directory
# of apache and start the http service
su -c "echo '<?php phpinfo() ?>' >$INST/htdocs/phpinfo.php; chmod +xr $INST/htdocs/phpinfo.php; apachectl restart"
# checking cli, should return "java running"
echo '<?php phpinfo() ?>' | php | fgrep java
# checking web, should return "java running"
wget -olog -O- http://localhost/phpinfo.php|fgrep java
If the above test succeeded, copy the files "java.so",
"libnatcJavaBridge.so" and "JavaBridge.jar" (on Windows: php_java.dll
and JavaBridge.jar) to the extension_dir of your system php
installation and start the system http service again.
The modules/ directory also contains a file "JavaBridge.war" which can
be used to run php within a pure java application server. Please see
the bottom of the INSTALL.J2EE document how to install it into IBM
WebSphere, Oracle 10g, Tomcat5 or others.
If something went wrong, for example if you have forgotten to set
JAVA_HOME or if configure failed because the installed autoconf
version is too old, you can only remove the build directory and start
from the beginning; removing the autom4te cache directories from the
build directory may be enough sometimes, but not always.
------------------------------------
Installation of Tomcat/mod jk
-----------------------------
Optionally you can install the tomcat servlet engine to serve .jsp
files
Download and extract tomcat into a directory, for example /opt/tomcat5
and set the environment variable CATALINA_HOME, for example:
export CATALINA_HOME=/opt/tomcat5
Download and install mod jk, for example
jakarta-tomcat-connectors-1.2.14.1-src.tar.gz, extract the file into a
folder and type the following commands:
cd jakarta-tomcat-connectors-1.2.14.1-src/jk/native/
./configure --with-apxs=$INST/bin/apxs && make && su -c "make install"
# now activate mod_jk in the httpd.conf, mount the tomcat webapps
# directory and ask tomcat to handle all .jsp files
su -c "echo -e 'LoadModule jk_module modules/mod_jk.so\nJkAutoAlias $CATALINA_HOME/webapps\nJkMount /JavaBridge/*.jsp ajp13\nJkMount /JavaBridge/ ajp13' >>$INST/conf/httpd.conf"
Start tomcat, for example with the command:
$CATALINA_HOME/bin/catalina.sh start
Copy the JavaBridge.war file (which you should have created when
compiling the PHP/Java Bridge, see flag "--enable-servlet" above) from
the modules directory into the tomcat webapps directory, for example
with the command:
cp modules/JavaBridge.war $CATALINA_HOME/webapps
Check if tomcat has created the $CATALINA_HOME/webapps/JavaBridge
directory, if not, please check the tomcat logs for errors.
Direct php to tomcat:
su -c "echo -e 'extension=java.so\n[java]\njava.servlet=User\njava.hosts=127.0.0.1:8080' >$INST/lib/php.ini"
Start or re-start apache, for example with:
su -c "apachectl restart"
Visit http://localhost/JavaBridge and run the supplied examples.
The php .ini file [java] section should contain only java.log_level,
java.servlet and java.hosts entries. Example:
[java]
java.log_level="2"
java.servlet=User
java.hosts="127.0.0.1:8080"
The PHP/Java Bridge log output appears in the server log file, for
example in $CATALINA_HOME/logs/localhost_log.*.txt
---------------------------------------------
Compiling the bridge without autoconf
-------------------------------------
Follow these instructions to create a java.so or php_java.dll on
systems which don't have autoconf or if ./configure fails (because the
installed autoconf scripts are too old).
To create a windows php_java.dll you'll need:
* A Unix machine with a C cross compiler, for example
386-pc-mingw32-gcc
* the standard windows includes in the ./include directory
* the MINGW includes in the ./include directory
* the php5ts.dll in the $PHP directory
* the configured php4 or php5 source distribution in the $PHP
directory
To create a unix java.so you'll need:
* A unix machine with a C compiler
* the standard unix includes in the /usr/include directory
* the configured php4 or php5 source distribution in the $PHP
directory
cd to the php-java-bridge* directory and type the following commands:
BRIDGE_VERSION="`cat ./VERSION`"
PHP_JAVA=""
COND_GCJ=0
EXTENSION_NAME=JAVA
# The java executable on windows or unix
#PHP_JAVA_BIN="javaw"
PHP_JAVA_BIN="java"
# The extension_dir on windows or unix
#EXTENSION_DIR="c:/php"
EXTENSION_DIR="."
# The configured PHP directory, this directory must contain
# the php4ts or php5ts shared library and the header files
#PHP="../php-5.0.3"
PHP="../php-4.4.0"
# The directory which contains the system include files
# for windows (+MINGW include files) or unix
#SYS_INCLUDE="../include"
SYS_INCLUDE="/usr/include"
# The (cross-) compiler for windows or unix
#GCC=386-pc-mingw32-gcc
GCC=gcc
# create init_cfg.h and init_cfg.c
for i in init_cfg.c init_cfg.h; do
sed "s*@PHP_JAVA@*${PHP_JAVA}*
s*@COND_GCJ@*${COND_GCJ}*
s*@PHP_JAVA_BIN@*${PHP_JAVA_BIN}*
s*@EXTENSION@*${EXTENSION_NAME}*
s*@BRIDGE_VERSION@*${BRIDGE_VERSION}*" \
<./${i}.in >./${i}
done
#compile command for windows (with ZTS)...
#$GCC -w -I$SYS_INCLUDE -I. -I$PHP -I$PHP/main -I$PHP/Zend -I$PHP/TSRM -D"TSRM_EXPORTS" -D"LIBZEND_EXPORTS" -D"ZTS" -D"_MBCS" -DCOMPILE_DL_JAVA -DCFG_JAVA_SOCKET_INET -DEXTENSION_DIR=\"$EXTENSION_DIR\" -c *.c
# ... or unix (without ZTS)
$GCC -w -I$SYS_INCLUDE -I. -I$PHP -I$PHP/main -I$PHP/Zend -I$PHP/TSRM -D"_MBCS" -DCOMPILE_DL_JAVA -DCFG_JAVA_SOCKET_INET -DEXTENSION_DIR=\"$EXTENSION_DIR\" -c *.c
#create the windows .dll or the unix .so file
#i386-pc-mingw32-dllwrap --export-all-symbols -k *.o -L$PHP -lphp5ts -lws2_32 -o php_java.dll
$GCC -shared *.o -Wl,-soname -Wl,java.so -o java.so