214 lines (154 with data), 7.1 kB
This file contains very detailed installation instructions. For most
users the command
phpize && ./configure --with-java=$JAVA_HOME && make
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 -tb php-java-bridge*.tar.gz). 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*; ./configure --prefix=$INST --disable-all --enable-fastcgi && make && make install)
(cd php-java-bridge*; phpize && ./configure --with-java=/usr/java/default && make && sh install.sh)
# test
php php-java-bridge*/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: a J2EE server or servlet engine, for example Apache-Tomcat
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)
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=/usr/java/default
#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
#
gunzip < php-x.y.z.tar.gz | 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"
# configure and build the J2EE ("php-cgi" fastcgi) component
./configure --prefix=$INST --disable-all
make && su -c "make install"
cd ..
#
# BUILD THE PHP/JAVA BRIDGE
#
gunzip < php-java-bridge_p.x.y.tar.gz | 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"
# (the <port> is the Listen port defined in $INST/conf/httpd.conf
# usually 80 or 8000)
wget -olog -O- http://localhost:<port>/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 INSTALL.J2EE document for details.
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.
If the above cli test succeeded but the web test failed, check if
something is blocking the defined http port, the system httpd service
for example.
------------------------------------
Installation of the J2EE component
----------------------------------
Copy the file "JavaBridge.war" to the autodeploy folder of your J2EE
server.
Copy the php-cgi executable to the system PATH or into the WEB-INF/cgi
folder within "JavaBridge.war" and add a .sh wrapper (see the
WEB-INF/cgi/README for details).
On Windows copy the php-cgi.exe and the phpXts.dll to the system PATH
or into the WEB-INF/cgi folder within "JavaBridge.war" (see the
WEB-INF/cgi/README for details).
------------------------------------
Apache/J2EE load balancer setup
-------------------------------
Assuming that there are 3 J2EE nodes running on diego, carlos and
localhost, append the following lines at the end of your apache
httpd.conf:
ProxyPass /JavaBridge balancer://mycluster maxattempts=3
<Proxy balancer://mycluster>
BalancerMember http://diego:8080/JavaBridge
BalancerMember http://carlos:8080/JavaBridge
BalancerMember http://localhost:8080/JavaBridge
</Proxy>
Restart Apache and start at least one node. Check
http://localhost/JavaBridge/jsp+php.jsp
and, if SSL is enabled
https://localhost/JavaBridge/jsp+php.jsp