Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > contrib-release > by-pkgid > 9bf6a3b5fdceb23c9b46553948f545aa > files > 28

php-java-bridge-5.0.0-0.0.2mdv2008.1.x86_64.rpm

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 --rebuild php-java-bridge*src.rpm).  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-5.*; ./configure --prefix=$INST --disable-all --enable-fastcgi && make && make install)
(cd php-java-bridge-3.*; phpize && ./configure --with-java=/usr/java/jdk1.5.0 && make && make install)

# test
php php-java-bridge-3.*/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: Oracle 9i/10g AS or IBM WebSphere 5/6.


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) for IBM WebSphere or Oracle AS.

and optionally, if you want to run JSP and PHP from Apache/Tomcat:

* mod_jk with Apache/Tomcat.

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"
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 Tomcat/mod jk
-----------------------------

Optionally you can install the tomcat servlet engine to serve .jsp
files

Download and extract tomcat into a directory, for example /opt/tomcat5
and set the environment variable CATALINA_HOME, for example:

export CATALINA_HOME=/opt/tomcat5


Download and install mod jk, for example
jakarta-tomcat-connectors-1.2.14.1-src.tar.gz, extract the file into a
folder and type the following commands:

cd jakarta-tomcat-connectors-1.2.14.1-src/jk/native/
./configure --with-apxs=$INST/bin/apxs && make && su -c "make install"

# now activate mod_jk in the httpd.conf, mount the tomcat webapps
# directory and ask tomcat to handle all .jsp files
su -c "echo -e 'LoadModule jk_module modules/mod_jk.so\nJkAutoAlias $CATALINA_HOME/webapps\nJkMount /JavaBridge/*.jsp ajp13\nJkMount /JavaBridge/ ajp13' >>$INST/conf/httpd.conf"

Start tomcat, for example with the command:

$CATALINA_HOME/bin/catalina.sh start


Copy the JavaBridge.war file (which you should have created when
compiling the PHP/Java Bridge, see flag "--enable-servlet" above) from
the modules directory into the tomcat webapps directory, for example
with the command:

cp modules/JavaBridge.war $CATALINA_HOME/webapps

Check if tomcat has created the $CATALINA_HOME/webapps/JavaBridge
directory, if not, please check the tomcat logs for errors.

Direct php to tomcat:
su -c "echo -e 'extension=java.so\n[java]\njava.servlet=User\njava.hosts=127.0.0.1:8080' >$INST/lib/php.ini"

Start or re-start apache, for example with:
su -c "apachectl restart"

Visit http://localhost/JavaBridge and run the supplied examples.

The php .ini file [java] section should contain only java.log_level,
java.servlet and java.hosts entries.  Example:

       [java]
       java.log_level="2"
       java.servlet=User
       java.hosts="127.0.0.1:8080"

The PHP/Java Bridge log output appears in the server log file, for
example in $CATALINA_HOME/logs/localhost_log.*.txt