Allow Java classes to be supported under PHP

Source: Internet
Author: User
Tags install php ini modify mysql version zts
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. 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





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 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 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!





Setting 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, write a test page test.php





;?


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





//demonstrate Property Access


print ' Java version= '. $system->getproperty (' java.version '). ' <br> ';


?>











Normal Words page should be able to display: 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.