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
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.
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.
/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 ');
// 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.
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.