PHP / Java Bridge is an interesting technology to allow to connect PHP with a Java virtual machine. On the official site they claim “It is more than 50 times faster than local RPC via SOAP, requires less resources on the web-server side, and it is faster and more reliable than communication via the Java Native Interface.”
http://php-java-bridge.sourceforge.net/pjb/
STEP 1: Compiling and installing Apache
$ tar xfvz apache_1.3.37.tar.gz
$ tar xfvz mod_ssl-2.8.28-1.3.37.tar.gz
$ cd mod_ssl-2.8.28-1.3.37
$ ./configure –with-apache=../apache_1.3.37
$ cd ../apache_1.3.37
$ SSL_BASE=/usr ./configure –prefix=/usr/local –enable-module=so \
–enable-module=speling –enable-module=rewrite –enable-module=ssl
$ make
$ make certificate TYPE=dummy
# make install
STEP 2: Compiling and installing php module
$ cd ..
$ tar xfvj php-5.2.1.tar.bz2
$ cd php-5.2.1
$ ./configure –enable-memory-limit \
–disable-url-fopen-wrapper –with-gd –enable-dbase –enable-exif \
–enable-ftp –with-gettext –with-iconv –enable-mbstring \
–with-jpeg-dir=/usr/lib –with-zlib-dir=/usr/lib –with-kerberos \
–with-png-dir=/usr/lib –enable-gd-native-ttf –with-freetype-dir=/usr/lib \
–with-openssl –with-xml –with-dom –disable-cgi –with-mcrypt \
–with-xsl –enable-javascript –with-mcal \
–with-sablot-js –with-readline \
–with-mysql –with-mysqli \
–with-config-file-path=/usr/local/conf/php-module \
–disable-cli –with-apxs=/usr/local/bin/apxs \
–with-curl
$ make
$ make install
# mkdir /usr/local/conf/php-module
# cp php.ini-recommended /usr/local/conf/php-module/php.ini
$ cd ..
STEP 3: Compiling and installing php cgi
$ cd ../php-5.2.1
$ ./configure –enable-memory-limit \
–disable-url-fopen-wrapper –with-gd –enable-dbase –enable-exif \
–enable-ftp –with-gettext –with-iconv –enable-mbstring \
–with-jpeg-dir=/usr/lib –with-zlib-dir=/usr/lib –with-kerberos \
–with-png-dir=/usr/lib –enable-gd-native-ttf –with-freetype-dir=/usr/lib \
–with-openssl –with-xml –with-dom –disable-cgi –with-mcrypt \
–enable-xslt –with-xslt-sablot –enable-javascript –with-mcal \
–with-sablot-js –with-readline \
–with-mysql –with-mysql \
–with-config-file-path=/usr/local/conf/php-cli \
–disable-cgi \
–with-curl
$ make
# make install
# mkdir /usr/local/conf/php-cli
# cp php.ini-recommended /usr/local/conf/php-cli/php.ini
$ cd ..
STEP 4: Installing PHP-Java Bridge
$ tar xfvz php-java-bridge_4.0.1.tar.gz
$ cd php-java-bridge-4.0.1
$ phpize && ./configure \
–with-java=/usr/local/jdk1.6.0,/usr/local/jdk1.6.0/jre \
&& make
# sh install.sh
Edit /usr/local/conf/php-module/php.ini to add the following lines:
extension_dir = “/usr/local/lib/php/extensions/no-debug-non-zts-20060613/”
extension=java.so
[Java]
java.class.path =
java.servlet = On
java.hosts=”localhost:8080″
java.persistent_connections=Off
;java.home = c:\jdk
;java.library = c:\jdk\jre\bin\hotspot\jvm.dll
;java.library.path = .\
STEP 5: Deploy JavaBridge.war
In order to use the JavaBridge extension the JavaBridge.war have to be deployed in tomcat
$ cp JavaBridge.war /usr/local/tomcat/webapps/
If Tomcat is running it will automatically deploy the application under webapps.

