Apache Web makes jsp "dynamic"

Source: Internet
Author: User
Tags unpack


---- JSP is a commonly used dynamic web page creation technology. However, Apache only supports static Web pages. Therefore, it must be used in conjunction with other specific application services. This article describes the latest practical technology that combines Apache and tomcat services to support JSP dynamic web pages, that is, using the "Apache/JK" method to support JSP dynamic web pages.
---- At first, Apache and tomcat combined to support JSP dynamic web pages through a plug-in named "mod_jserv. The configuration parameters in this Apache/Jserv mode are very complex and inefficient, and the support for SSL (an encrypted transmission mode) is not ideal, therefore, the Jakarta Working Group has recently developed the "mod_jk" plug-in, which makes up for the shortcomings of mod_jserv and supports a variety of web services other than Apache.
---- For the implementation principle of this Apache/JK method, you can read the relevant information on the website. This article only briefly introduces the implementation method and does not discuss the principle part.
---- 1. Install On UNIX platform
---- This article takes the most common Solaris operating system as an example.
---- (1) application environment
---- Here, we use the Solaris 2.7 operating system, and the application environment is Java 1.2 (assuming that it is installed in the/usr/java1.2 directory), Perl 5.005 (which is installed in the/usr/local/bin directory) and gzip (which is assumed to be installed in the/usr/local/bin directory ).
---- (2) download, compile, and install the software package
---- 1.
---- Download the latest Apache Source code The software package is apache_1.3.19.tar.gz.
---- Download the Tomcat Source Code Software Package jakarta-tomcat-3.2.1-src.tar.gz.
---- Download the compiled Tomcat application package jakarta-tomcat-3.2.1.tar.gz.
---- 2. Compilation and Installation
---- If the software packages have been downloaded to a working directory (for example,/home/tmp), Apache and Tomcat will be installed in the/home directory. In the current directory, we can perform the following operations.
(1) Compile and install the Apache Application Service
① Unpack
$/Usr/local/bin/gzip-DC./apache_1.3.19.tar.gz | tar xf-
② Compile
$ CD apache_1.3.19
$./Configure -- prefix =/home/Apache-1.3.19.
-- With-perl =/usr/local/bin/perl -- enable-module = so
Assume that the Perl Command is installed in the/usr/local/bin directory,
Install Apache in the/home/Apache-1.3.19 directory.
$ Make
③ Installation
$ Su
# Make install
(2) Compile and install the mod_jk plug-in
① Unpack
$/Usr/local/bin/gzip-DC jakarta-tomcat-3.2.1-src.tar.gz | tar xf-
② Compile
$ CD jakarta-tomcat-3.2.1-src/src/native/apache1.3
$/Home/Apache-1.3.19/bin/apxs-O mod_jk.so-dsolaris-I ../JK-I/
Usr/java1.2/include-I/usr/java1.2/include/
Solaris-lposix4-C *. C ../JK/*. c
Assume that Java is installed in the/usr/java1.2 directory.
③ Installation
$ Su
#/Home/Apache-1.3.19/bin/apxs-I-a-n Jk mod_jk.so
If the following content is displayed, the installation is successful.
CP mod_jk.so/home/Apache-1.3.19/libexec/mod_jk.so
Chmod 755/home/Apache-
1.3.19/libexec/mod_jk.so
[Activating module 'jk in/home/Apache-1.3.19/CONF/httpd. conf]
(3) install the Tomcat Service
Decompress compiled Tomcat 3.2.1 to the/home directory as a Super User.
$ Su
#/Usr/local/bin/gzip-DC Co., jakarta-tomcat-3.2.1.tar.gz |
(CD/home; tar xf -)
3. parameter configuration
(1) configure the apache service
Run the VI command to open the configuration file httpd. conf of Apache.
# Cd/home/Apache-1.3.19/Conf
# Vi httpd. conf
Add the following content at the end.
Jkworkersfile/home/jakarta-tomcat-3.2.1/CONF/workers. Properties
Jklogfile/home/Apache-1.3.19/logs/mod_jk.log
Note: The log file can be adjusted as needed.
Jkloglevel warn
Jkmount/*. jsp ajp13
Jkmount/servlet/*. jsp ajp13
Note: Other important items in the configuration file are not related to Tomcat.
For more information, see apache documentation.
(2) configure the Tomcat Service
First, modify the server. xml file.
Assume that the root directory of the web page that stores Apache is/home/htdocs.
# Cd/home/jakarta-tomcat-3.2.1/Conf
# Vi server. xml
Then, embed the following content in the connectors section.
<Connector classname = "org. Apache. tomcat. Service.
Pooltcpconnector "> <parameter name =" handler"
Value = "org. Apache. tomcat. Service. connector. AJP
13 connectionhandler "/>
<Parameter name = "Port" value = "8009"/>
</Connector>
Then, embed the following content in the special webapps section.
<Context Path = ""
Docbase = "/home/htdocs"
DEBUG = "0">
</Context>
Modify the workers. properties file.
# Vi workers. Properties
...
Workers. tomcat_home =/home/jakarta-tomcat-3.2.1
...
Workers. java_home =/usr/java1.2
...
PS =/
...
Then modify tomcat to start and close the command file.
# CD ../bin
# Vi startup. Sh
Embed the following content before the "basedir = 'dirname $ 0'" statement.
Path =/usr/java1.2/bin: $ path :.
Java_home =/usr/java1.2
Tomcat_home =/home/jakarta-tomcat-3.2.1
Export path java_home tomcat_home
# Vi shutdown. Sh
Finally, embed the following content before the "basedir = 'dirname $ 0'" statement.
Path =/usr/java1.2/bin: $ path :.
Java_home =/usr/java1.2
Tomcat_home =/home/jakarta-tomcat-3.2.1
Export path java_home tomcat_home
4. Test
Start Apache and tomcat respectively.
#/Home/Apache-1.3.19/bin/apachectl start
#/Home/jakarta-tomcat-3.2.1/bin/startup. Sh
Then, edit the simple. jsp test file.
# Vi/home/Apache/-1.3.19/htdocs/test. jsp
<HTML>
<Head>
<Title> This is a JSP test file!
</Title>
</Head>
<Body>
<% Out. Print ("this is a JSP test file! N "); %>
</Body>
</Html>
Finally, browse the Web page.
---- Open the browser and access the. jsp file: http: // host name (or IP address)/test. jsp. If the content shown in the figure is displayed on the screen, it indicates that the JSP Dynamic Webpage file is running normally.

2. Installation on Windows NT/2000 Platform
---- This article takes Windows 2000 as an example.
---- (1) application environment
---- The operating system uses Windows 2000, the application environment is Java 1.2.2 (assuming it has been installed on the C: jdk-1.2.2) and WinZip.
---- (2) download and install the software package
---- The installation on Windows nt2000 is relatively simple. You only need to download the compiled software package on the website without re-compiling the application software.
---- 1.
---- Download the latest compiled Apache package apache_1.3.19-Windows32-no_src-r2.msi.
---- Download mod_jk.zip.
---- Download jakarta-tomcat-3.2.1.zip.
---- 2. Install
---- First, double-click "apache_1.3.19-Windows32-no_src-r2.msi" to install the apache service.
---- Then extract "mod_jk.zip" to the "modules" subdirectory of the Apache service, and finally extract "jakarta-tomcat-3.2.1.zip" to the C: directory.
---- 3. parameter configuration
---- (1) modify the configuration file httpd. conf of the Apache service
---- Note: This article only involves tomcat-related parameters. For other parameter settings, see related Apache documentation.
---- Click Start with the mouse "*" Program "*" Apache httpd server "*" Configure Apache server "*" Edit configuration ".
---- Embed the following content in the "dynamic shared object (DSO) support" section.
Loadmodule jk_module modules/mod_jk.dll
Finally, add the following content at the end of the file.
Jkworkersfile C: jakarta-tomcat-3.2.1confworkers.properties
Jklogfile C: jakarta-tomcat-3.2.1logsmod_jk.log
Jkloglevel warn
Jkmount/*. jsp ajp13
Jkmount/servlet/* ajp13
(2) configure the Tomcat Service
---- Adjust the parameters of the server. xml and workers. properties files. You can refer to the section corresponding to the Unix section. However, you should note that for different levels of directories, UNIX is separated by "/", while windows is separated.
---- Edit the startup. BAT and shutdown. BAT files respectively, and embed the following content in line 3 of the file.
Set tomcat_home = C: jakarta-tomcat-3.2.1
Set java_home = C: jdk1.2.2
Set Path = C: jdk1.2.2bin;.; % PATH %.
4. Test
Refer to the corresponding section of the UNIX section for testing.
---- This article only briefly introduces the configuration and usage of Apache/JK, In the tomcat configuration file (such as server. XML), there are many parameters that can be adjusted according to the actual situation, which are not described here. Interested readers can refer to the prompt information in the configuration file or relevant information on the website for further adjustment and testing.
---- (Yan Peng's address: China Economic Network Corporation, National Information Center, No. 58 sanlihe Road, Xicheng District, Beijing, 100045)

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.