System requirements:
The hardware can run the operating system
Preparation for
Win2K, WinXP or Win2003 operating system
:
Required software list: (This configuration is completed with the following software versions)
1. APACHE_2.0.47-win32-x86-no_ssl (Apache web server)
2. PHP-4.3.3-Win32 (PHP language parser)
3. MySQL-4.0.12-win (MySQL database)
4. j2sdk-1_4_2-windows-i586 (JAVA language environment)
5. Jakarta-Tomcat-5.0.9 (Tomcat JSP parsing server)
6. Resin-3.0.3 (Resin JSP parsing server)
7. mod_jk_1.2.5_2.0.47.dll (plus that integrates Apache+Tomcat)
8. mm.mysql-2.0.4-bin.jar (JSP access MySQL file)
Start the installation:
1. Apahce+PHP+MySQL installation configuration
1. Install APACHE_2.0.47-win32-x86-no_ssl, the default installation path of the program is :C:apache2program filesapache Group, you need to modify its installation path to: C:
(You don’t need to make any modifications, it’s mainly for the convenience of modifying the configuration).
2. After the installation is completed, the apache service is automatically loaded. At this time, open the browser and browse: http://localhost . The apache welcome page will appear (this step requires the file "index.html.en" in the C:apache2htdocs directory. ” to “index.html” before it can be displayed); if an exception occurs in this step, please check the installation source file and reinstall.
3. Install PHP-4.3.3-Win32. Generally, the downloaded PHP file is an installation-free compressed package. Just unzip it to C:PHP.
4. Configure PHP and Apache so that they can parse PHP programs.
PHP configuration: Rename "php.ini-dist" in the C:PHP directory to "php.ini" and copy it to C:windowssystem32 (Win2K directory is: C:winntsystem32)
Apache configuration:
C:apahce2confhttpd.conf
httpd.conf
DAdd the following statement at the end of this configuration file to support php programs:
ScriptAlias /php/ "C:/PHP/"
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php.exe"
5. Restart the Apache server and write the following statement in the editor:
<?
phpinfo();
?>
Save the file name "test.php" to the C:apache2htdocs directory, then open the browser and browse to: http://localhost/test.php . If basic PHP information appears, it means the configuration is successful. Strictly follow the above instructions to install and configure, and it will be successful the first time.
6. Install MySQL-4.0.12-win, keep pressing "next" and the installation will be successful. Then execute "winmysqladmin.exe" in the C:mysqlbin directory. The initial information page of mysql will appear, indicating that the installation is successful.
7. PHP and MySQL are skipped here, generally there is no problem.
At this point you can take a break and prepare for the long process below...
2. Install JDK and Tomcat
1. Install j2sdk-1_4_2-windows-i586. JDK must be installed before Tomcat and Resin. The default installation path is sufficient.
2. Install Jakarta-Tomcat-5.0.9, the default installation path is sufficient.
3. Copy the mm.mysql-2.0.4-bin.jar file to C:j2sdk1.4.2lib and C:Tomcat 5.0commonlib respectively
4. Set environment variables (Desktop->My Computer->Right-click->Select "Properties"->Advanced->Environment Variables), all settings are made in the system variables column.
New->Variable name: JAVA_HOME
->Variable value: C:j2sdk1.4.2
New->Variable name: TOMCAT_HOME
->Variable value: C:Tomcat 5.0
New->Variable name: PATH
->Variable value: .;C:j2sdk1.4.2bin; (the preceding ".;" must be present)
Modify and add the environment variable CLASSPATH (if there is no such variable name, create a new one)
->Add variable value: .;C:j2sdk1.4.2libdt.jar;C:j2sdk1.4.2libtool.jar;
C:j2sdk1.4.2libNetComponents.jar;
C:j2sdk1.4.2libmm.mysql-2.0.4-bin.jar;
C:Tomcat 5.0commonclasses;
C:Tomcat 5.0commonlib;
C:Tomcat 5.0commonlibservlet-api.jar;
(the ".;" in front must be there)
5. Start the Tomcat server, open the browser, browse: http://localhost:8080/ , Tomcat appears Welcome page; if there is an exception in this step, please check the installation source file and reinstall.
3. Integrate Apache+Tomcat server
1. Copy the mod_jk_1.2.5_2.0.47.dll file to the C:Apache2modules directory.
2. Apache configuration:
C:apahce2confhttpd.conf
httpd.conf
Add the following statement at the end of this configuration file to support jsp programs:
LoadModule jk_module modules/mod_jk_1.2.5_2.0.47.dll
JkWorkersFile "C:/Tomcat 5.0/conf/workers.properties"
JkMount /servlet/* ajp13
JkMount /*.jsp ajp13
3. Check whether the port "8009" in the C:Tomcat 5.0confserver.xml file is commented. If it is consistent with my version, no modification is needed.
4. In the C:Tomcat 5.0conf directory, create a new file named "workers.properties" and copy the following content to the new file workers.properties.
workers.properties
# Just copy the following content:
# This is currently modified according to the installation directory
workers.tomcat_home=C:Tomcat 5.0
workers.java_home=C:j2sdk1.4.1_01
ps=
# worker.list=ajp13
worker.list=ajp12,ajp13
worker.ajp12.port=8007
worker.ajp12.host=localhost
worker.ajp12.type=ajp12
worker.ajp12.lbfactor=1
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp12, ajp13
worker.inprocess.type=jni
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)classes
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)jaxp.jar
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)parser.jar
worker. inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)jasper.jar
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$ (ps)servlet.jar
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)webserver.jar
worker.inprocess.class_path=$(workers.java_home)$(ps )lib$(ps)tools.jar
worker.inprocess.cmd_line=-config
worker.inprocess.cmd_line=$(workers.tomcat_home)/conf/jni_server.xml
worker.inprocess.cmd_line=-home
worker.inprocess.cmd_line=$ (workers.tomcat_home)
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)jvm.dll
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)inprocess.stderr
worker.inprocess.sysprops=tomcat.home=$( workers.tomcat_home)
5. At this point, the integration of Apache and Tomcat is completed. Restart the Apache and Tomcat servers.
Use the editor to write the following content:
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>HI-JSP Experiment</title>
</head>
<body>
<%
String Msg = "This is JSP test! After seeing this, congratulations, you succeeded!";
out.print("Hello World!");
%>
<h3><%=Msg%></h3>
The current date and time is <%=new java.util.Date() %>
<br>
<%
String str = "Using trim() and substring() can be very useful";
out.println(str);
%>
</body>
</html>
Save the file name "test.jsp" to the C:Tomcat 5.0webappsROOT directory, then open the browser and browse: http://localhost:8080/test.jsp . If the display is normal, then change the address to: If http://localhost/test.jsp displays normally, it means the configuration is successful. Strictly follow the above instructions to install and configure, and it will be successful the first time.
4. Integrating Apache+Tomcat+MySQL
This step is relatively simple, but it is also the least likely to succeed. The MySQL driver of JSP has been placed in the corresponding directory and the environment variables have also been set, so it is just to test whether JSP can connect to MySQL. database.
1. Test 1, use the editor to write the following content:
<%@ page contentType="text/html;charset=gb2312" %>
<%
java.sql.Connection conn;
java.lang.String strConn;
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn= java.sql.DriverManager.getConnection("jdbc:mysql://localhost/test","root","");
%>
Note: The database here is: test. The user name to connect to the database is: root. The password is empty. Make corresponding modifications according to your own database.
Save the file named "test-mysql.jsp" to the C:Tomcat 5.0webappsROOT directory, then open the browser and browse: http://localhost:8080/test-mysql.jsp or http://localhost/ test-mysql.jsp , after running, if a blank page is displayed, it means the connection to the database is successful, otherwise it means the connection is not successful, please go back and configure carefully step by step.
2. Test 2, use the editor to write the following content:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.sql.*"%>
<%
Connection conn = null;
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/test","root","");
if(conn==null){
System.out.println("get Conn Error");
}
Statement stmt=conn.createStatement();
ResultSet RS_result=null;
%>
<html>
<head>
<title>Test</title></head>
<body>
<%
RS_result=stmt.executeQuery("select * from guestbook");
String Name;
while(RS_result.next())
{
Name=RS_result.getString("name");
%>
<%=Name%>
<%
}
RS_result.close();
stmt.close();
conn.close();
%>
</body>
</html>
Save the file named "test-mysql2.jsp" to the C:Tomcat 5.0webappsROOT directory, then open the browser and browse: http://localhost:8080/test-mysql2.jsp or http://localhost/ test-mysql2.jsp , after running.
5. Install Resin and integrate Apache+Resin
1. Assume that no other JSP parsing server is started on the machine. If it is started, please close the service.
2. Unzip Resin-3.0.3.zip directly to C:
3. Use the command in character mode: C:resin-3.0.3binhttpd –install
Install Resin as a service on the system, and then start Resin in the service.
Delete service command: C:resin-3.0.3binhttpd –remove
4. Open the browser and browse to: http://localhost:8080 . If Resin information is displayed, the Resin service has been started.
5. Apache configuration:
C:apahce2confhttpd.conf
httpd.conf
Add the following statement at the end of this configuration file:
LoadModule caucho_module C:/resin-3.0.3/libexec/apache-2.0/mod_caucho.dll
<IfModule mod_caucho.c>
ResinConfigServer localhost 6802
<Location /caucho-status>
SetHandlercaucho-status
</Location>
</IfModule>
AddHandler caucho-request jsp
<Location /servlet/*>
SetHandlercaucho-request
</Location>
Save and restart apache.
6. Resin configuration:
C:resin-3.0.3confresin.conf
resin.conf
Modify the default directory:
<server>
<host id="">
<document-directory>C:Apache2htdocs</document-directory>
...
</host>
</server>
After completion, save it, restart the Resin service, store the edited JSP file in the C:Apache2htdocs directory, then open the browser to browse, and you can freely jump between PHP and JSP.