Installing the PHP/Java Bridge on Linux
---------------------------------------

On RedHat Enterprise Linux ("RHEL") or Fedora Linux ("FC") download
and install the java, PHP, httpd and php-java-bridge RPM files. You
need to download the following PHP/Java Bridge RPM files:

  For PHP 4 (>= 4.3.2): php-java-bridge-x.y.z-1.RHEL.i386.rpm
  For PHP 5.0.x       : php-java-bridge-x.y.z-1.FC4.i386.rpm
  For PHP >= 5.1.1    : php-java-bridge-x.y.z-1.FC5.i386.rpm

------------------------------------------------------------------------
On other Linux variants please either create a binary RPM distribution
from the source RPM, for example with the command:

   rpmbuild --rebuild php-java-bridge*src.rpm

or, if you have downloaded the source tarball, use the commands:

   tar xjf php-java-bridge_*.tar.bz2
   cp php-java-bridge-*/php-java-bridge.spec /usr/src/redhat/SPECS
   cp php-java-bridge_*.tar.bz2 /usr/src/redhat/SOURCES
   rpmbuild -bb /usr/src/redhat/SPECS/php-java-bridge.spec

or follow the instructions from the generic INSTALL.J2EE document
instead.
------------------------------------------------------------------------

Install the RPM files, for example with:

    rpm -i j2re-1_4_2_09-linux-i586.rpm
    rpm -i httpd-2.y.z-p.i386.rpm
    rpm -i php-x.y.z-p.i386.rpm
    rpm -i php-java-bridge-x.y.z-p.i386.rpm

Either install the tomcat back-end:

    rpm -i tomcat5-x.y.z-p.i386.rpm
    rpm -i php-java-bridge-tomcat-x.y.z-p.i386.rpm

Or install the standalone back-end:

    rpm -i php-java-bridge-standalone-x.y.z-p.i386.rpm

Or deploy the J2EE back-end:

    Copy the JavaBridge.war to the autodeploy folder of your J2EE
    server and edit the java.hosts and java.servlet options in
    /etc/php.d/java.ini, see the INSTALL.J2EE document for details.

If Security Enhanced Linux is enabled, the above commands should have
provided instructions how to install the php-java-bridge.te and
php-java-bridge.fc policy files.


J2EE/Servlet back-end
----------------------

If you have installed the tomcat or J2EE back-end, check the PHP .ini
settings. If the Apache document root should not be shared with the
J2EE or servlet webapps directory, set java.servlet to On, example:

  java.hosts=127.0.0.1:8080; or 8888 for Oracle, 9080 for WebSphere
  java.servlet=On

If the Apache document root should be shared with the J2EE or servlet webapps
directory, set java.servlet to User:

  java.hosts=127.0.0.1:8080; or 8888 for Oracle, 9080 for WebSphere
  java.servlet=User

and change the DocumentRoot and Directory setting in the Apache httpd
configuration file /etc/httpd/conf/httpd.conf. Old lines marked with 
a -, added lines with a +:

    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    #
  - DocumentRoot "/var/www/html"
  + DocumentRoot "/usr/share/tomcat5/webapps"
  [...]
    # This should be changed to whatever you set DocumentRoot to.
    #
  - <Directory "/var/www/html">
  + <Directory "/usr/share/tomcat5/webapps">

The above example assumes that the shared webapps directory is
/usr/share/tomcat5/webapps. Change it accordingly.


Re-start the tomcat or J2EE back-end and the Apache HTTP server, for example with:
    
    service tomcat5 restart
    service httpd restart

and browse to;

    http://localhost:8080/JavaBridge/test.php 
    http://yourHost/JavaBridge/test.php


Standalone back-end
-------------------

If you have installed the standalone back-end, re-start the back-end
and apache, copy the test.php from the documentation folder
(/usr/share/doc/php-java-bridge-[version]) to the web server document
root (/var/www/html) and check:

    http://yourHost/test.php


Custom Libraries
----------------

You can install your java libraries (.jar files) in extension_dir/lib
(see output of phpinfo) or in the J2EE back-end's WEB-INF/lib folder
or in /usr/share/java/ext or /usr/share/java.

All java libraries located in extension_dir/lib, /usr/share/java/ext
and WEB-INF/lib (for the J2EE/servlet back-end) are automatically
loaded whenever the JVM starts.

Impure java libraries (=libraries which use the java native interface)
must be stored in /usr/share/java/ext or extension_dir/lib. Shared
libraries required by the impure java libraries must be stored in the
java.library.path, which is usually the PHP extension_dir.

Java libraries which should be loaded or re-loaded on demand can be
stored in a sub-directory of /usr/share/java or in a sub-directory of
extension_dir/lib. They can be linked into the PHP files at run-time
using the command java_require("library1.jar;library2.jar;..."), see
the README for details.


Optional: Translating Java to PHP classes
-----------------------------------------

PHP classes can be created from Java libraries with the command:

   java -jar JavaBridge.jar --convert /usr/share/pear JAVALIBRARY.jar

The PHP classes are installed in /usr/share/pear/JAVALIBRARY

Please see the README and http://php-java-bridge.sourceforge.net
for further information.
