Development environment integrating JSP, PHP, and JAVA (1)

Source: Internet
Author: User
Article title: JSP, PHP, and JAVA integrated development environment (1 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   Preface
This article introduces the establishment of a development environment integrating JSP, PHP, and JAVA. to meet the needs of most beginners, many steps are easy to use and strive to be simple and clear. Generally, I use RPM to install software without special requirements. If you have special requirements such as optimized configuration and security considerations, please refer to relevant articles for configuration.
  
In this article, Apache is installed in DSO mode, and PHP supports JAVA components, so that PHP can be used as the front-end scripting language during large-scale project development, call JAVA components to implement underlying and enterprise-level applications.
  
   1. system environment
   1. initial installation
Open Firewall interfaces:, eth0
Redhat in 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
: Http://www.netshine.com.cn/linux/j2sdk-1_4_2_04-linux-i586.rpm
  
Tomcat 5.0.19
: Http://www.netshine.com.cn/linux/jakarta-tomcat-5.0.19.tar.gz
  
   3. script installation
Webmin 1.110
: Http://www.netshine.com.cn/linux/webmin-1.110.tar.gz
  
ZendOptimizer 2.5.1
: Http://www.netshine.com.cn/linux/ZendOptimizer-2.5.1-Linux_glibc21-i386.tar.gz
  
   4. manual compilation
Apache 2.0.49
: Http://www.netshine.com.cn/linux/httpd-2.0.49.tar.gz
  
PHP 4.3.5
: Http://www.netshine.com.cn/linux/php-4.3.5.tar.gz
JK 2-2.0.4
: 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
Win CVS 1.3
: Http://www.netshine.com.cn/linux/WinCvs13b17.zip
  
   II. system installation
Start the Linux installation CD and install the basic system FTP, development tools, and MySQL3.23.54. If you compile and install MySQL manually, remember to specify the specific MySQL path when compiling PHP or other programs. otherwise, compilation errors may occur because the path cannot be found.
  
   3. install webmin1.110
Webmin can be used to configure the system, which is foolish and can save a lot of effort. Therefore, I usually install it first. The installation process is very simple. execute the setup. sh script and follow the prompts to start step by step.
  
# Cd webmin *
#./Setup. sh
  
   4. install JDK1.4.2
1. edit the following three files without specifying the full path in your 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)
{
// Test whether the Java environment is successfully installed.
System. out. println ("Hello World! ");
}
}
  
   2. run the following command:
  
# Rpm-ivh j2sdk *. rpm // install the JDK package.
# Source/etc/profile // reload the profile environment.
# Ldconfig // create a dynamic link library cache file.
# Javac-d. HelloWorld. java // compile the test file.
# Java HelloWorld // run the program to test whether the installation is successful.
  
   5. install Apache
# Tar xvzf httpd * // extract the source code package.
# Cd httpd * // enter the installation directory.
#./Configure -- prefix =/usr/local/apache -- enable-so -- enable-MoD-shared = most -- enable-rewrite
# Make; make install // compile and install.
  
   Note:
-- Enable-so option: enables Apache to support the DSO mode. Note that the Apache2.0 syntax is used here. If your Apache version is 1.3, change it to -- enable-module = so.
  
-- Enable-MoD-shared = most option: Tells the compiler to compile all standard modules into DSO modules. If you use Apache1.3, change it to -- enable-shared = max.
  
-- Enable-rewrite option: Supports address rewriting. if you are using version 1.3, change it to -- enable-module = rewrite.
  
   6. Compile and install PHP
  
   1. run the command
# Tar xvzf php * // decompress the source code package
# Cd php * // enter the 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 the php configuration file
# Cd/usr/local/php/lib/php/extensions/no-debug-non-zts-20020429 // extensions directory
# Ln-s java. so libphp_java.so // establish a connection. if you forget it, an error will occur.
# Cd Zend * // enter the ZendOptimizer Directory
#./Install // install the PHP accelerator
  
   Note:
-- With-apxs2 =/usr/local/apache/bin/apxs is the syntax of Apache2. for versions 1.3, 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
  
Adddefacharcharset gb2312
  
/Usr/local/apache/htdocs/test. php
   // This program tests whether the JAVA environment of PHP is available,
The code is extracted from 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 ').'
';
Echo 'Java vendor = '. $ system-> getProperty ('Java. upload ').'
';
Echo 'OS ='. $ system-> getProperty ('OS. name ').''.
$ System-> getProperty ('OS. version'). 'on '.
$ System-> getProperty ('OS. arch ').'
';
  
// 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
  
   Note:
(1). If you have just switched from the old version of PHP to the new version, you may find that many of your PHP programs are useless. Don't be nervous! It's okay to open register_globals! This is because the register_globals of the old version of PHP is open by default, but the new version is disabled.
  
(2)./home/jim/myclass is the path for storing JAVA components. you can modify the path according to the actual situation, but do not place it in the web Directory for security reasons.
  
  
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.