JSP, PHP and Java integration of the development environment 1

Source: Internet
Author: User
Tags install php ini mysql pack php and zts tomcat zend
JS Preface

This paper introduces the establishment of the development environment of the melting JSP, PHP and Java in a stove, in order to suit the needs of the most beginners, many steps are to use more convenient method, and strive to be simple and clear. In general, there is no special requirements of the software, I have to use the RPM way to install. If you have specific requirements for optimal configuration, security considerations, please refer to the relevant articles for configuration.

In this article, Apache in the DSO mode installation, PHP implementation of the Java component support, so that we are in large-scale project development, you can choose PHP as a front-end scripting language, invoke Java components to implement the low-level and enterprise-class applications.

I. SYSTEM environment

1. Initial installation

Firewall Open Interface: 21,22,80,2401,8009,10000,eth0
Redhat Linux 9.0
Development Tools

Network Servers
Vsftp
Cvs-1.11.2-10
MySQL 3.23.54

2. Package Installation

JDK 1.4.2_04
Download Address: http://www.netshine.com.cn/linux/j2sdk-1_4_2_04-linux-i586.rpm

Tomcat 5.0.19
Download Address: http://www.netshine.com.cn/linux/jakarta-tomcat-5.0.19.tar.gz

3. Script Installation

Webmin 1.110
Download Address: http://www.netshine.com.cn/linux/webmin-1.110.tar.gz

Zendoptimizer 2.5.1
Download Address: http://www.netshine.com.cn/linux/ZendOptimizer-2.5.1-Linux_glibc21-i386.tar.gz

4. Manual compilation

Apache 2.0.49
Download Address: http://www.netshine.com.cn/linux/httpd-2.0.49.tar.gz

PHP 4.3.5
Download Address: http://www.netshine.com.cn/linux/php-4.3.5.tar.gz
JK 2-2.0.4
Download Address: http://www.netshine.com.cn/linux/jakarta-tomcat-connectors-jk2-src-current.tar.gz

5. Client Environment

Windows XP Professional
Absolute Telnet 3.0
Zend Encoder
Macromedia Dreamweaver MX 2004
Borland JBuilder 9 Enterprise
Wincvs 1.3
Download Address: Http://www.netshine.com.cn/linux/WinCvs13b17.zip

Two. System Installation

Start the Linux installation CD and install the basic system: FTP, development tools, and MySQL3.23.54. If you are compiling the installation of MySQL manually, you should remember to compile PHP and other programs to specify the specific path of MySQL, otherwise the path will not find the resulting compilation error.

Three. Install webmin1.110

With Webmin to configure the system, fool, can save a lot of energy, so I usually install it first. The installation process is simple, follow the prompts step by step after executing the setup.sh script.

# CD webmin*
#./setup.sh



Four. Install JDK1.4.2

1. Edit the following three files without specifying the full path in your own home directory.

/etc/profile
Java_home=/usr/java/j2sdk1.4.2_04
Classpath=.: $JAVA _home/lib: $JAVA _home/jre/lib
Cvsroot=/usr/local/cvsroot
Path=.: $JAVA _home/bin: $JAVA _home/jre/bin: $PATH
Export Java_home CLASSPATH cvsroot PATH

/etc/ld.so.conf
/usr/java/j2sdk1.4.2_04/jre/lib/i386
/usr/java/j2sdk1.4.2_04/jre/lib/i386/server

Helloworld.java
Class HelloWorld
{
public static void Main (string[] args)
{
This file tests whether the Java environment was successfully installed.
System.out.println ("Hello world!");
}
}



2. Execute the following command:

# RPM-IVH j2sdk*.rpm//install JDK package.
# Source/etc/profile//Overload profile environment.
# Ldconfig//Create dynamic link library cache file.
# javac-d. Helloworld.java//Compile test file.
# java HelloWorld//Run program test whether the installation was successful.



Five. Install Apache

# tar Xvzf httpd*//Extract source pack.
# CD httpd*//Enter the installation directory.
#./configure--prefix=/usr/local/apache--enable-so--enable-mods-shared=most--enable-rewrite
# Make;make Install//compile and install.



Description

--ENABLE-SO option: Let Apache support DSO mode, note that we are here to use the Apache2.0 syntax. If your Apache is version 1.3, you should change to--enable-module=so.

--enable-mods-shared=most option: Tells the compiler to compile all standard modules into the DSO module. If you use Apache1.3, change to--enable-shared=max.

--enable-rewrite option: Support address rewrite, use 1.3 version of Friends please change it to--enable-module=rewrite.

Six. Compile and install PHP

1. Executive Order

#tar Xvzf php*/extract Source Pack
#cd php*//Enter PHP installation command
#./configure--prefix=/usr/local/php--with-mysql--with-apxs2=/usr/local
/apache/bin/apxs--with-java=/usr/java/j2sdk1.4.2_04
#make make install//compile and install
#cp php.ini-dist/usr/local/php/lib/php.ini//Copy PHP configuration file
#cd/usr/local/php/lib/php/extensions/no-debug-non-zts-20020429//extensions Directory
#ln-S java.so libphp_java.so//Set up a connection, forget that there will be mistakes OH
#cd zend*//Enter Zendoptimizer directory
#./install//install PHP accelerator



Description

--WITH-APXS2=/USR/LOCAL/APACHE/BIN/APXS is the APACHE2 syntax, the 1.3 version of the user please use--WITH-APXS=/USR/LOCAL/APACHE/BIN/APXS.

2. Edit the following three files

/usr/local/apache/conf/httpd.conf
LoadModule Php4_module modules/libphp4.so

AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps

Adddefaultcharset gb2312

/usr/local/apache/htdocs/test.php
<?php
This program tests whether PHP's Java environment is available,
The code is extracted from the http://www.php.net/manual/en/ref.java.php.

Get instance of Java class Java.lang.System in PHP
$system = new Java (' Java.lang.System ');

Demonstrate property access
Echo ' Java version= '. $system->getproperty (' java.version '). ' <br/> ';
Echo ' Java vendor= '. $system->getproperty (' Java.vendor '). ' <br/> ';
Echo ' os= '. $system->getproperty (' Os.name '). ' ' .
$system->getproperty (' os.version '). ' On '.
$system->getproperty (' Os.arch '). ' <br/> ';

java.util.Date Example
$formatter = new Java (' Java.text.SimpleDateFormat ',
"Eeee, MMMM dd, yyyy ' at ' h:mm:ss a zzzz");

Echo $formatter->format (New Java (' java.util.Date '));
?>

/usr/local/php/lib/php.ini
Register_globals=on
[Java]
Java.class.path=/usr/local/php/lib/php/php_java.jar:/home/jim/myclass
Java.home=/usr/java/j2sdk1.4.2_04
Java.library=/usr/java/j2sdk1.4.2_04/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=libphp_java.so



Attention:

(1). If you have just switched from a previous version of PHP to a new version, you may find that many of your PHP programs are useless. Take it easy! Turn the register_globals on and everything's fine! This is because the old version of PHP, its register_globals default is open, and the new version, but turned it off.

(2)./home/jim/myclass is the path to my Java component, you can modify it according to the actual situation, but for the sake of security, do not put it under the Web directory OH.


Related Article

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.