Installation from RPM
---------------------
* Install a J2RE, for example with the command:
rpm -i IBMJava2-JRE-1.4.1-8.i386.rpm
* Install PHP, for example with the command:
rpm -i php-4.3.2-8.ent.i386.rpm
* Install the web-server, for example with the command:
rpm -i httpd-2.0.46-25.ent.i386.rpm
* Install the php-java-bridge, for example with the command:
rpm -i php-java-bridge-X.Y.Z-1.i386.rpm
* If you have SECURITY ENHANCED LINUX, the above command should have
provided instructions how to install the php-java-bridge.te and
php-java-bridge.fc policy files. If you encounter problems, for
example if the default policy is too restrictive, please report them
to php-java-bridge-users@lists.sourceforge.net and include the
relevant audit log: "dmesg | fgrep avc:".
Start the web-server with the command: service httpd restart.
Start the bridge with the command: service php-java-bridge restart
Create a simple php file in /var/www/html, for example with
the command: echo "<?php phpinfo(); ?>" >/var/www/html/phpinfo.php.
Browse to http://localhost/phpinfo.php and search for the
output of the php java bridge module (the entry should be:
"java.support: Enabled").
Then install your java classes in java.libpath (see output of
phpinfo), your java libraries (.jar files) in /usr/share/java or in
java.libpath/lib and your php and web-pages in /var/www/html.
--------------------------------------------------
--------------------------------------------------
Installation from source code
-----------------------------
NOTE: If you run a SELinux kernel, you must install the policy files
before you can run the PHP/Java Bridge. The php-java-bridge source
tarball contains the policy files in the root directory. Please see
the README file.
The following software components must be installed on your computer:
* an operating system, for example RedHat Enterprise Linux
* a Java VM, for example IBM JDK 1.4.1
The following software components are required to run PHP scripts with
java code embedded via a web-server. It is assumed that these
components are not already installed on your computer. If they are,
change the install directory or skip the compilation/install steps for
these components:
* PHP 4.3.x or above, for example 5.0.1
* the PHP/Java Bridge version 1.x
* a web-server, for example Apache 2.x
Then choose a proper INST directory and type the following commands:
# adjust install directory
INST=/usr/local
# 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
# stop the system http service
su - -c "service httpd stop"
# 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 ..
# compile and install php 4.3
bunzip2 < php-4.3.x.tar.bz2 | tar xf -
cd php-4.3.x
./configure --prefix=$INST --without-java --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 ..
# compile and install the php/java bridge
bunzip2 < php-java-bridge_1.x.y.tar.bz2 | tar xf -
cd php-java-bridge-1.x.y
export PATH=$INST/bin:$PATH
export LD_LIBRARY_PATH=$INST/lib:$LD_LIBRARY_PATH
phpize
./configure --with-java=/opt/IBMJava2-141
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 ..
# 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