search
Homephp教程php手册Redhat 9.0下让PHP支持Java类

Redhat 9.0下让PHP支持Java类

Jun 13, 2016 am 10:33 AM
javalinuxphpredhatBundlesupportkind

要在linux下的php支持java类,故把我的调试笔记贴出来,希望对大家有用。

系统环境:

Redhat 9.0
Apache-1.3.27
Mysql3.23-54a-11
Php-4.32
j2sdk1.4.1_03

安装配置:

1.mysql使用的是redhat9自带的rpm包,不介绍安装了,jdk的安装也很简单,我们把jdk安装到/usr/java/j2sdk1.4.1_03 并在/etc/profile设置jdk环境参数。

2.编译安装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.编译安装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


修改/usr/local/apache/conf/httpd.conf

查找

在此范围添加

<ccid_code></ccid_code>AddType application/x-httpd-php .php
            AddType application/x-httpd-php-source .phps


4.配置php.ini

cp php.ini.dist /usr/local/php/lib/php.ini

vim php.ini

修改如下内容:

<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


保存退出。

cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20020429

ln –s java.so libphp_java.so 这一步很重要哦!

设置环境变量:

export LD_LIBRARY_PATH=/usr/java/j2sdk1.4.1_03/jre/lib/i386:/usr/java/j2sdk1.4.1_03/jre/lib/i386/server

ok!重启一下apache

/usr/local/apache/bin/apachectl start

测试一下,写个测试页test.php

<ccid_code></ccid_code>
            $system=new Java("java.lang.System");
            //demonstrate property access
            print Java version=.$system->getProperty(java.version). <br>;
            ?>


正常的话页面应该能显示:Java version=1.4.1_03
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function