Recently in Linux, PHP support Java classes, I put the debugging notes after finishing the summary written out, I hope that the future debugging will help.
System environment:
Redhat 9.0
Apache-1.3.27
Mysql3.23-54a-11
Php-4.32
J2sdk1.4.1_03
Installation configuration:
1. MySQL is using Redhat9 's own RPM package, does not introduce installation, JDK installation is also very simple, we install JDK to/usr/java/j2sdk1.4.1_03 and set JDK environment parameters in/etc/profile.
2. Compile and install Apache
tar zvxf apache_1.3.27.tar.gz
cd apache_1.3.27
./configure –prefix=/usr/local/apache
–enable-module=so –enable-shared=max
make
make install
3. Compiling and installing PHP
tar zvxf php-4.3.2.tar.gz
cd php-4.3.2
./configure –prefix=/usr/local/php –with-mysql \
--with-apxs=/usr/local/apache/bin/apxs \
--with-java=/usr/java/j2sdk1.4.1_03
make
make install
Modify/usr/local/apache/conf/httpd.conf, find, add in this range
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
4. Configure PHP.ini
CP Php.ini.dist/usr/local/php/lib/php.ini
Vim php.ini
Modify the following:
[Java]
java.class.path = /usr/local/php/lib/php/php_java.jar
java.home = /usr/java/j2sdk1.4.1_03
java.library = /usr/java/j2sdk1.4.1_03/jre
/lib/i386/libjava.so
java.library.path =/usr/local/php/lib/php
/extensions/no-debug-non-zts-20020429
extension_dir = /usr/local/php/lib/php
/extensions/no-debug-non-zts-20020429
extension=java.so
Save exit.
cd/usr/local/php/lib/php/extensions/no-debug-non-zts-20020429 ln–s java.so libphp_java.so This step is very important oh!
To set environment variables:
Export Ld_library_path =/usr/java/j2sdk1.4.1_03/jre/lib/i386:/usr/java/j2sdk1.4.1_03/jre/lib/i386/server good! Restart Apache/usr/local/apache/bin/apachectl start
Test, write a test page test.php
<?
$system=new Java("java.lang.System");
//demonstrate property access
print 'Java version='.$system->getProperty('java.version').' <br>';
?>
Normal page should be able to display: Java version=1.4.1_03