测试环境 redhat9.0,Apache2.0.40,PHP 4.4.2,j2sdk1.4.2_13,j2sdk1.4.2_13,jre1.5,php-java-bridge_3.2.1

假设事先apache,php已经安装配置好.

安装j2sdk1.4.2_13到www.sun.com上下在rpm安装包,安装之

1
# rpm -ivh j2sdk-1_4_2_13-linux-i586.rpm

vim /root/.bashrc
加入

1
2
3
4
5
6
set JAVA_HOME=/usr/java/j2sdk1.4.2_13
export JAVA_HOME
set PATH=$PATH:$JAVA_HOME/bin
export PATH
set CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:/opt/myclass
export CLASSPATH

安装jre1.5.0_09到www.sun.com上下在rpm安装包,安装之

1
2
3
# rpm -ivh jre-1_5_0_09-linux-i586.rpm
# ls /usr/java
j2sdk1.4.2_13 jre1.5.0_09

安装php-java-bridge,下载地址:http://sourceforge.net/projects/php-java-bridge 下载源码包

解压缩

1
2
#tar zxvf php-java-bridge_3.2.1.tar.gz
#cd php-java-bridge-3.2.1

编译&连接

1
#phpize && ./configure —with-java=/usr/java/j2sdk1.4.2_13,/usr/java/jre1.5.0_09 && make

安装

1
#make install

扩展包会生成在这个目录
/usr/local/lib/php/extensions/no-debug-non-zts-20020429

配置php.ini 加入

1
2
3
4
5
6
7
[Java]
java.class.path =”/usr/local/lib/php/extensions/no-debug-non-zts-20020429;/opt/myclass”
java.home =/usr/java/j2sdk1.4.2_13
java.library =/usr/java/j2sdk1.4.2_13/lib
java.library.path =/usr/local/lib/php/extensions/no-debug-non-zts-20020429
extension_dir = /usr/local/lib/php/extensions/no-debug-non-zts-20020429
extension=java.so

重启apache

1
# apachectl restart