I want to support Java classes in PHP under Linux, so I posted my debugging notes. I hope it will be useful to everyone.
System environment:
Redhat 9.0
Apache-1.3.27
Mysql3.23-54a-11
Php-4.32
j2sdk1.4.1_03
Installation configuration:
1. Mysql uses the rpm package that comes with redhat9. I will not introduce the installation. The installation of jdk is also very simple. We install jdk to /usr/java/j2sdk1.4.1_03 and set the jdk environment parameters in /etc/profile.
2. Compile and install apache
<ccid_code></ccid_code>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. Compile and install php
<ccid_code></ccid_code>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
to this range
<ccid_code></ccid_code>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 content:
<ccid_code></ccid_code>[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 and 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!
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
ok! Restart apache
/usr/local/apache/bin/apachectl start
Test it out and write a test page test.php
<ccid_code></ccid_code><?
$system=new Java("java.lang.System");
//demonstrate property access
print Java version=.$system->getProperty(java.version). <br>;
?>
|
If normal, the page should be able to display: Java version=1.4.1_03
http://www.bkjia.com/PHPjc/508508.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508508.htmlTechArticleIn order to support java classes in PHP under Linux, I posted my debugging notes. I hope it will be useful to everyone. System environment: Redhat 9.0 Apache-1.3.27 Mysql3.23-54a-11 Php-4.32 j2sdk1.4.1_03 Installation configuration...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn