Windows Server + Tomcat + MySQL + jsp + php Server integrated configuration experience summary

Source: Internet
Author: User
Tags php server
Summary of Windows Apache + Tomcat + MySQL + jsp + php Server integrated configuration experience, read Windows Apache + Tomcat + MySQL + jsp + php Server integrated configuration experience, 1. author: moonsbird Title: Server integrated configuration by Apache + Tomcat + MySQL + jsp + php in Windows

1. author: moonsbird
Title: Windows Server integrated configuration experience of Apache + Tomcat + MySQL + jsp + php
Time: 2004.8.19
Originally published on Jincheng station of Southwest Jiaotong University
2. This article is a summary of the author's experience in learning jsp/configuring server environments over the past few years. It can be reproduced, but please indicate the source.

I have been learning jsp for a long time. There are many examples of jsp integration on the Internet, but there are many problems.
The integration of Apache + Tomcat + MySQL + jsp + php is slightly different for different Tomcat and apache versions.
Even if you have a good E-paper, you may not be able to fully integrate the Tomcat and Apache manuals. At home during summer vacation, the network speed is not as high
As in Jiaotong University-the old scalper is slow in pulling the car sample. Therefore, based on this author's query of a large amount of online information, he likes his essence and writes this article
This chapter also serves as a reference manual for beginners.
Jsp is excellent. based on Java technology, it uses JavaBean/Servlet to create dynamic websites.
Image programming gives Jsp a unique advantage over php and asp. However, learning jsp is more difficult than php and asp.
I think one of the reasons is that the configuration of the jsp server environment is tricky. For the production of dynamic web pages, it was a long time before asp at Jiaotong University.
There are not many "Masters" (maybe many people think that jsp is a master ).
Jsp websites such as Century Star Network (Tomcat), Network Education College website (Resin), Jiaotong university enrollment and employment network (Tomcat), the server is
Linux 9 is relatively stable and reliable. I have published an article on the integration of Apache and Tomcat in Linux.
If you want to search in Jincheng. The integration idea in linux and windows is the same. apache is used to parse *. html/*. htm.
For static web pages, when *. jsp and servlet are encountered, the jsp page is thrown to Tomcat through a module in apache (or
Resin) to handle, compile in linux to make this module, it is a bit of trouble, this article through a ready-made Windows
Module to complete integration.
If you don't talk about it, integrate the following:

Required software
(1) j2sdk-1_4_2-windows-i586.exe
The jdk Version relationship is not very big, and does not affect the integration of Apache and Tomcat. just pay attention when configuring environment variables.
(2) apache_2.0.49-win32-x86-no_ssl.exe
The apache version does not have much impact on integration, but it is best to use it.
(3) jakarta-tomcat-4.1.30.exe
It is best to use this version. I have not tried any other version, and it may cause the integration to fail.
(3) php-4.3.3-Win32.zip
Is a compressed package, download it and decompress it directly.
(4) mod_jk.dll
This module is placed in the module of apache, which enables communication between Tomcat and Apache.
(5) mysql-max-3.23.46a-win.zip
The mysql database version has little impact on integration.
(6) jdbc driver
Mysql driver, used to connect to the database
I will not post the down address for the above Software. I will go to the Internet to search for baidu and Peking University Skynet. if I try to find the address, I should ask questions.
Not big. if you cannot find it, send it to me.

1. install j2sdk
Run the j2sdk-00004_000001-windows-i586.exe file in Windows.
To a directory, such as install to d: \ server \ j2sdk
1. configure environment variables:
Add CLASSPATH variable
Variable value:
./; % CLASSPATH %; D: \ server \ j2sdk1.4.0 \ lib \ dt. jar; d: \ server \ j2sdk1.4.0 \ lib \ tools. jar;
D: \ server \ j2sdk1.4.0 \ bin
This configuration ensures that the class can be found during java runtime.
2. add the JAVA_HOME variable. the variable value is d: \ server \ j2sdk1.4.0.
3. in the original path variable, add d: \ server \ j2sdk1.4.0 \ bin, so that you can run the java name command wherever you are.
Restart

Cmd enters dos and runs java and javac to check whether there is any response. if the command is helpful, the java installation is successful.
You can also run a java applet.

Public class test {
Public static void main (String args []) {
System. out. println ("It indicates that java is successfully installed! ");
}
}
Store the program in the test. java file. it must be test. java, and then use the command to compile
Javac test. java
If there is no error, it indicates that the compilation is successful. if there is a mistake, the java environment variable does not
You have configured it. you just need to reconfigure it. If the compilation is successful, run:
Java test
Note: it is not java test. java! If it is correct, the following output is printed:

The java installation is successful!

Gxgx: jdk has been installed successfully! You can proceed to the next step.

II. install apache
1.run apache_2.0.49-win32-x86-no_ssl.exe. just click "OK" and "accept". select the path.
D: \ server \ apache group \ apache2.
At this time, apache has been installed successfully and is running. enter in IE to see
Apache homepage. Installed successfully!
2. modify httpd. conf
The configuration file of apache is httpd. conf, which is located in the conf folder under the apache root directory.
(1). modify the default website root directory:
Create the www folder under d: \ server as the root directory of the website.
DocumentRoot "D:/server/Apache Group/Apache2/htdocs"
Change to DocumentRoot "D:/server/www
(2). modify character settings
Apache generates garbled characters when parsing Chinese webpages,
Modify adddefadefacharset ISO-8859-1 to adddefacharcharset GB2312
(3). modify the default homepage
Apache automatically imports the home page when accessing the directory. the priority is based on the order of priority.
Change DirectoryIndex index.html. var
DirectoryIndex index.html index. jsp index. php default. jsp default. php index.html. var
(4). set error page
In this way, your website will be safer. if you do not set it, if you enter a path after your website, the error 404 will be displayed.
The version number of your server is displayed, and the server configuration is clear at a glance. to avoid this situation, you can set an error page.
When a 404 error occurs, that is, the webpage cannot be found, the visitor is imported to an error page.
Find:
#
# Customizable error responses come in three flavors:
#1) plain text 2) local redirects 3) external redirects
#
# Some examples:
# ErrorDocument 500 "The server made a boo ."
# ErrorDocument 404/missing.html
# ErrorDocument 404 "/cgi-bin/missing_handler.pl"
# ErrorDocument 402
#
This part in httpd. conf, # ErrorDocument 404/missing.html
Change a row to ErrorDocument 404/error/nofile.htm, and the value of nofile.htm is d: \ server \ www \ error \ next error file.
You need to create it yourself. When a error occurs, enter the nofile.htm page and you will be prompted that the page is not found. In this way, you cannot see
Your server software information. You can also set other error-oriented pages. For more information about the http response error numbers, see.
Restart apache. If no accident occurs, the installation is successful. put the static page in the d: \ server \ www \ error \ directory to check whether the parsing can be successful.
Enter http: // localhost/sdagasgdasasg.htm, which indicates that the 404error is incorrect, that is, the nofile.htm error page.
Succeeded!
I will not mention the meaning of other parameters in apache. you can check them online. In fact, the best way is to check the comments in httpd. conf.
Points, you have already made it very clear.
Now, apache is successfully installed. you can take a break, listen to the music, and start the next installation :)

III. install php
Decompress php-4.3.3-win32.zip to the directory d: \ server \ php. configure PHP and Apache to parse the php program.
Rename "php. ini-dist" in the d: \ server \ php \ directory and copy it to C: \ windows \ system32
(The Win2K directory is C: \ winnt \ system32). in the apache configuration file httpd. conf, enter the following lines
Supports php.
ScriptAlias/php/"d:/server/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"
Create a webpage: index. php under d: \ server \ www with the following content:

Php testing
Phpinfo ();
?>

Use the text editor to edit it as index. php, restart apache, and enter it in IE.
Environment variable, indicating that php is successfully installed. if it cannot be parsed Is not installed successfully.

4. Tomcat installation
I use the jakarta-tomcat-4.1.30.exe installation file. in windows, click "OK". the installation directory is
D: \ server \ tomcat
Set the environment variables as follows:
Add the TOMCAT_HOME variable to the environment variable of jdk. The value is d: \ server \ tomcat. add the variable CATALINA_HOME. The value is
D: \ tomcat \ server, add d: \ server \ tomcat \ bin to the path variable
Start tomcat and run the bin/startup. bat file in the tomcat Directory. the tomcat running console is displayed, and tomcat is successful.
Start.
Enter it in IE and check that tomcat is installed successfully.

5. install MySQL

Step 1: unzip the mysql-max-3.23.46a-win.zip, run the mysql installation file, install mysql to d: \ server \ mysql
Step 2: Add d: \ server \ mysql \ bin to the environment variable path
Step 3: Go to the d: \ server \ mysql \ bin directory and run winmysqladmin. the dialog box appears, set the mysql User password, assuming
The root account password is 123.
Step 4: Go to dos, go to mysql/bin, and run the following command to open mysql
Mysqld-nt -- standalone
Mysql is enabled.
Then run:
Mysql
If enabled, the following text appears:
Welcome to the MySQL monitor. Commonds end with; or \ g.
Your MySQL connection id is 1 to server version: 3.23.46-nt
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
Mysql>
Note: No password is set for mysql at this time. to prevent others from entering your database, set a password for mysql. for detailed operations, see mysql
.
So far, mysql has been installed successfully!

6. install MySQL driver jdbc
Unbind the jdbc driver package and copy the org folder to a location that can be found in jsp. It can be the tomcat root directory common/classes
Folder, can also be jsp site class WEB-INF/class. When the driver is loaded, you can find related classes. Or set the jdbc package
To the classpath variable.

VII. integrated configuration of Tomcat and Apache
Tomcat is just a container used to parse *. jsp files. it is not a server, and its ability to parse static htm/html files is far inferior to apache,
After integration, apache is used to parse static web pages on the same port. in the case of *. jsp web pages, it is resolved by tomcat.
Step 1: copy mod_jk.dll to the module folder in the apache root directory.
Step 2: Configure APACHE

Open conf \ httpd. conf in the apache root directory.

Add the following statement:

#------------------------------------------

# Connecting to tomcat using ajp13
LoadModule jk_module modules/mod_jk.dll
JkWorkersFile "d:/server/tomcat/conf/workers. properties"
JkMount/servlet/* ajp13
JkMount/*. jsp ajp13


#-----------------------------------------------------

Note: The above statements basically mean:
LoadModule: load the mod_jk.dll dynamic link library module to communicate with tomcat.
JkWorkersFile: specifies the location of the tomcat-related file workers. properties at work.
JkMount: the two lines indicate that when *. jsp and servlet are encountered, they are handed over to the ajp13 protocol and then forwarded to tomcat for processing.
Step 3: Create the workers. properties file and create the workers. properties file under the conf directory of tomcat. the content is:
Workers. tomcat_home = d: \ server \ tomcat
Workers. java_home = d: \ server \ j2sdk1.4.0
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. worker _line =-config

Worker. inprocess. worker _line = $ (workers. worker at_home)/conf/jni_server.xml

Worker. inprocess. worker _line =-home

Worker. inprocess. worker _line = $ (workers. worker at_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)

Note that the first and second lines of the above files fill in the relevant directories of tomcat and jdk.
 
Step 4: configure the server. xml file under CMDA/conf. this is the main configuration file of tomcat. the important configuration is as follows:
1. virtual directory settings:
Find the following content:
UnpackWARs = "true" autoDeploy = "true">
To:
UnpackWARs = "true" autoDeploy = "true">
Make tomcat home directory d: \ server \ www.
Find the following content:
Reloadable = "true" crossContext = "true">
Change
Reloadable = "true" crossContext = "true">
My understanding is that jsp under the tomcat root directory should be used as a virtual host.
2. set the tomcat listening port and find the following content:
Port = "8080" minProcessors = "5" maxProcessors = "75"
EnableLookups = "true" redirectPort = "8443"
AcceptCount = "100" debug = "0" connectionTimeout = "0"
UseURIValidationHack = "false" disableUploadTimeout = "true"/>
The default port number is 8080, but we all know that it is best to modify it. if it is changed to 8123, it is as follows:
Port = "8123" minProcessors = "5" maxProcessors = "75"
EnableLookups = "true" redirectPort = "8443"
AcceptCount = "100" debug = "0" connectionTimeout = "0"
UseURIValidationHack = "false" disableUploadTimeout = "true"/>
3. find the following Port 8009. this is very important. through Port 8009, tomcat communicates with apache. if the following section
Quilt Comment out, make sure Remove.

Port = "8009" minProcessors = "5" maxProcessors = "75"
EnableLookups = "true" redirectPort = "8443"
AcceptCount = "10" debug = "0" connectionTimeout = "0"
UseURIValidationHack = "false"
ProtocolHandlerClassName = "org. apache. jk. server. JkCoyoteHandler"/>
Step 5: configure the conf/web. xml file of tomcat:
Similar to the configuration of the 404 error page in apacheAdd the following content before a row:


404
/Error/noFile.htm


Java. lang. NullPointerException
/Error. jsp

First When 404 does not find the error-oriented page of the jsp page,
The webpage directs to/error/noFile.htm. you can also use a similar method to add many error code-oriented pages.
Second When java. lang. NullPointerException occurs on jsp pages
Go to the/error. jsp error page. Add the following content to the first jsp page:
<% @ Page errorPage = "/error. jsp" %>
The typical error. jsp error page program is written as follows:

<% @ Page contentType = "text/html; charset = GB2312" %>
<% @ Page isErrorPage = "true" %>

Error Page


Error:

Error message: <% = exception. getMessage () %>

Stack Trace is:

<%
    java.io.CharArrayWriter cw = new java.io.CharArrayWriter();
    java.io.PrintWriter pw = new java.io.PrintWriter(cw,true);
    exception.printStackTrace(pw);
    out.println(cw.toString());
    %>



When an NullPointerException exception occurs, tomcat imports the webpage to error. jsp and prints the error message.
Step 5 focuses on security considerations. under normal circumstances, if the webpage cannot be found, the 404 error or jsp program error may occur.
The following information is listed (using tomcat as an example, resin is similar ):
HTTP Status 404-/sdags. jsp

--------------------------------------------------------------------------------

Type Status report

Message/sdags. jsp

Description The requested resource (/sdags. jsp) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.19

In this way, the server version will be seen by others. if the configuration in step 5 is completed, this will not happen.
Step 6: configure the httpd. conf file
In this way, the root directory of tomcat and apache is set to the same directory, but you must restrict access to some files in the directory, such
To add the following code under httpd. conf:
# Deny the access to WEB-INF

Order allow, deny
Deny from all

In this way, apache rejects the question.

By now, the integration of tomcat and apache is complete. restart tomcat and apache,
Place the jsp webpage under d: \ server \ www \, for example:

JSP test

<% Out. println ("Hello World! "); %>


Saved as index. jsp, input in IE
If
Hello World!
It indicates that tomcat is running normally. enter it in IE. if so
Hello World!
Congratulations! Integration is successful, and you have taken a big step on the long and difficult way of jsp ~!

I have completed the above Integrated articles in a rush and may be wrong. Or you may not consider the week, but the overall plan should not
This is a big problem. I have used this method repeatedly to successfully integrate it. If you have any questions, contact me directly.
Moonsbird: mail: pengw97@163.com

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.