Support Java classes in PHP

Source: Internet
Author: User
System environment: Redhat9.0Apache-1.3.27Mysql3.23-54a-11php-4.32j2sdk1.4.20.03 installation configuration: 1. mysql uses the rpm package that comes with redhat9. if you do not describe the installation, jdk installation is simple. we install jdk to usrjavaj2sdk1.4.1 _ 03 and set jdk environment parameters in etcprofile. 2. Compile and install the apacheta 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. if you do not describe the installation, jdk installation is also very simple, install jdk in/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. Compile and install 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

Search

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 content:

[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. write a test page named test. php.

$ System = new Java ("java. lang. System ");

// Demonstrate property access
Print 'Java version = '. $ system-> getProperty ('Java. version ').'
';
?>



Normally, the page should be displayed: Java version = 1.4.1 _ 03

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.