Home  >  Article  >  Backend Development  >  Let PHP support java classes under Redhat Linux 9_PHP tutorial

Let PHP support java classes under Redhat Linux 9_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:32:38741browse

Copyright statement: You can reprint at will. When reprinting, please be sure to indicate the original source and author information of the article and this statement in the form of a hyperlink

http://www.5ilinux.com/apache(Unix platform is the most popular WEB server platform)02.html


Redhat Linux 9 allows php (as the current mainstream development language) to support java classes

Due to the needs of the company's business, PHP (as the current mainstream development language) under Linux recently needs to support the Java class, so I posted my debugging notes, hoping it will be useful to everyone.

System environment:
Redhat 9.0
apache(the most popular WEB server platform on Unix platform)-1.3.27
MySQL(matched with PHP The best combination)3.23-54a-11
php(as the current 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. I won’t introduce the installation. The installation of jdk is also very simple. We install the jdk to /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 platform)
tar zvxf apache(The most popular WEB server platform on Unix platform)_1.3.27.tar.gz
cd apache(The most popular WEB server platform on Unix platform)_1.3.27
./configure –prefix=/usr/local/apache(The most popular WEB server platform on Unix platform) –enable-module=so –enable-shared=max
make
make install

3. Compile and install php(as the current mainstream development language)
tar zvxf php(as the current mainstream development language)-4.3.2.tar.gz
cd php(as the current mainstream development language)-4.3.2
./configure –prefix=/usr/local/php(as the current mainstream development language) –with-MySQL(The best combination with PHP)
--with-apxs=/usr/local/apache(The most popular WEB server platform on Unix platform)/bin/apxs
--with-java=/usr/java/j2sdk1.4.1_03
make
make install

Modify /usr/local/apache(Unix The most popular WEB server platform) /conf/httpd.conf
Find

Add in this scope

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

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

vim php(as the current mainstream development language) Mainstream development languages) .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)/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 current mainstream development language)/lib/php(as the current mainstream development language)/extensions/no-debug-non-zts- 20020429
extension_dir = /usr/local/php(as the current mainstream development language)/lib/php(as the current mainstream development language)/extensions/no -debug-non-zts-20020429
extension=java.so
Save and exit.
cd /usr/local/php(as the current mainstream development language)/lib/php(as the current mainstream development language)/extensions/no-debug -non-zts-20020429
ln –s java.so libphp(as the current 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 platform)
/usr/local/apache(The most popular WEB server platform on Unix platform)/bin/apache(The most popular WEB server platform on Unix platform)ctl start

Test it and write a test page test.php(as the current mainstream development language )
$system=new Java("java.lang.System");

//demonstrate property access(favorite for small websites)
print Java version=.$system->getProperty(java.version). ;
?>
If normal, the page should be able to display: Java version=1.4.1_03


Author: Zhang Weibo

2003-07-05 in Beijing

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508688.htmlTechArticleCopyright statement: You can reprint it at will. When reprinting, please be sure to indicate the original source and author information of the article and this article in the form of a hyperlink. Statement http://www.5ilinux.com/apache (the most popular WEB server on the Unix platform...
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