Support java classes for PHP in Redhat linux 9

Source: Internet
Author: User

Copyright Disclaimer: You can reprint the document at will. During reprinting, you must mark the original source and author information of the article as hyperlinks and this statement.

Http://www.5ilinux.com/apache (unixplatform most popular Web server platform %02.html


In Redhat linux 9, php (as the mainstream development language) supports java classes.

Due to the business needs of the company, php under linux (as the current mainstream development language) supports java classes recently, so I posted my debugging notes, hoping to be useful to everyone.

System Environment:
Redhat 9.0
Apache (the most popular WEB server platform on Unix)-1.3.27
MySQL (best combination with PHP) 3.23-54a-11
Php (as a mainstream development language)-4.32
J2sdk1.4.1 _ 03

Installation Configuration:
1. mySQL (the best combination with PHP) 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 (the most popular WEB server platform on Unix)
Tar zvxf apache(the most popular Web server platform of UNIX platform pai_1.3.27.tar.gz
Cd apache (the most popular WEB server platform on Unix) _ 1.3.27
./Configure-prefix =/usr/local/apache (the most popular WEB server platform on Unix)-enable-module = so-enable-shared = max
Make
Make install

3. Compile and install php (as the mainstream development language)
Tar zvxf PHP (the current development language is ‑4.3.2.tar.gz)
Cd php (as the mainstream development language)-4.3.2
./Configure-prefix =/usr/local/php (as the mainstream development language)-with-MySQL (the best combination with PHP)
-- With-apxs =/usr/local/apache (the most popular WEB server platform on Unix)/bin/apxs
-- With-java =/usr/java/j2sdk1.4.1 _ 03
Make
Make install

Modify/usr/local/apache (the most popular WEB server platform on the Unix platform)/conf/httpd. conf
Search

Add in this range

AddType application/x-httpd-php (as the mainstream development language). php (as the mainstream development language)
AddType application/x-httpd-php (as the mainstream development language)-source. php (as the mainstream development language) s

4. Configure php (as the mainstream development language). ini
Cp php (as the mainstream development language ). ini. dist/usr/local/php (as the mainstream development language)/lib/php (as the mainstream development language ). ini

Vim php (as the mainstream development language). ini


Modify the following content:
[Java]
Java. class. path =/usr/local/php (as the current mainstream development language)/lib/php (as the current mainstream development language) _ 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 (as the mainstream development language)/lib/php (as the mainstream development language)/extensions/no-debug-non-zts-20020429
Extension_dir =/usr/local/php (as the mainstream development language)/lib/php (as the mainstream development language)/extensions/no-debug-non-zts-20020429
Extension = java. so
Save and exit.
Cd/usr/local/php (as the mainstream development language)/lib/php (as the mainstream development language)/extensions/no-debug-non-zts-20020429
Ln-s java. so libphp (as the mainstream development language) _ 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 (the most popular WEB server platform on Unix)
/Usr/local/apache (the most popular WEB server platform on the Unix platform)/bin/apache (the most popular WEB server platform on the Unix platform) ctl start

Test it and write a test page test. php (as the mainstream development language)
<?
$ 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


Author: Zhang microwave

In Beijing

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.