Article Title: let PHP support large projects. 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
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
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. execute 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
/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.
7. install Tomcat 1. execute the following command
# Cd * jk2 */jk/native2 // enter the connector compilation Directory
#./Buildconf. sh // run the configuration script
#./Configure -- with-apxs2 =/usr/local/apache/bin/apxs -- enable-jni -- enable-EAPI
# Make // compilation module
# Cd ~ Jim/src/* jk2 */jk/build/jk2/apache2 // enter the Directory of the compiled module
# Cp *. so/usr/local/apache/modules // Copy the module to the Apache Directory
# Cp-R jakarta-tomcat-5.0.19/usr/local/tomcat // install Tomcat
# Touch/usr/local/apache/logs/shm. file // create a shared memory file
When I first started to install Tomcat, I always failed. then I ran to the Apache website and read a two-page English description. I soon configured it. I found that Chinese authors always like to learn more about it. they make complicated things and make them easy to understand.
2. edit the following files
/Usr/local/apache/conf/httpd. conf
LoadModule jk2_module modules/mod_jk2.so
JkSet config. file/usr/local/apache/conf/workers2.properties
DocumentRoot "/usr/local/tomcat/webapps"
/Usr/local/tomcat/webapps/jsp-examples/for. jsp
<%
Int I;
For (I = 1; I <100; I ++)
{
Out. println (" Hello World! ");
}
%>
/Usr/local/tomcat/conf/jk2.propertie
Handler. list = request, container, channelSocket
ChannelSocket. port = 8009
ChannelSocket. address = 127.0.0.1
ChannelSocket. maxPort = port + 10
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.