142 lines (102 with data), 5.1 kB
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 your java libraries (.jar files) in /usr/share/java
or in java.libpath/lib (see output of phpinfo) and your php and
web-pages in /var/www/html or one of their sub-directories.
Individual classes (.class files) cannot be loaded, please create a
.jar archive, for example with the command:
jar cvf myLibrary-<version>.jar *.class
and copy the library to /usr/share/java or one of its sub-directories
(if it is of general interest) or to java.libpath/lib, see output of
phpinfo.php above or one of its sub-directories (if it should be
visible to the PHP/Java Bridge only). At run-time your library can be
referenced with the command:
java_set_library_path("myLibrary-<version>.jar");
Please see the README and ABOUT.HTM for details.
--------------------------------------------------
--------------------------------------------------
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
installed (including development packages), 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
* 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"
# 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, it is recommended to compile 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")
# 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_p.x.y.tar.bz2 | tar xf -
cd php-java-bridge-p.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