Apache|js|web Apache is currently the most widely used Web application service on the Internet, it can not only be completely free, but also the performance is very reliable, its various functional modules can be flexibly combined to use as needed. At the same time, technicians can also be on the basis of its existing two development, so much favored by users.
JSP is a more commonly used Dynamic Web page production technology, but the Apache itself only supports static web pages, so it needs to be used in conjunction with other specific application services. This article is to introduce a combination of Apache and Tomcat services to support JSP Dynamic Web pages of the latest practical technology, that is, "APACHE/JK" way to support JSP Dynamic Web pages.
Initially, Apache and Tomcat support JSP Dynamic Web pages through a plugin called "Mod_jserv". This apache/jserv configuration parameter is very complex, inefficient operation, and SSL (a cryptographic transmission mode) support is not ideal, so the Jakarta team has recently developed a "MOD_JK" plug-in, it is a good way to compensate for the shortcomings of Mod_jserv, and can support a variety of Web services outside of Apache.
Regarding this kind of apache/jk way realization principle, everybody may go to the Http://jakarta.apache.org website to read the related material, this article only briefly introduces its realization method, to the principle part does not discuss.
First, install on the UNIX platform
This article describes the most common Solaris operating system as an example.
(i) Application environment
Here, the operating system we choose is Solaris 2.7, and the application is Java 1.2 (assumed to be installed in the/usr/java1.2 directory), Perl 5.005 (assumed to be installed in the/usr/local/bin directory) and gzip (assumed to be installed in the/usr/ Local/bin directory).
(ii) Download, compilation and installation of software packages
1. Download Address
The latest Apache source code package apache_1.3.19.tar.gz can be downloaded at http://www.apache.org. In http://jakarta.apache.org/builds/tomcat/release/v3.2.1/src/you can download the Tomcat source code package jakarta-tomcat-3.2.1-src.tar.gz.
In http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.1/bin/ You can download the compiled Tomcat application package jakarta-tomcat-3.2.1.tar.gz.
2. Compiling and installing
Assuming that the packages are downloaded to a current working directory (such as:/HOME/TMP), Apache and Tomcat will be installed in the/home directory. In the current directory we can do the following.
(1) Compiling and installing Apache application services
① Solution Package
$/usr/local/bin/gzip-dc./apache_1.3.19.tar.gz | Tar XF- |
② compilation
$ cd apache_1.3.19 $/configure--prefix=/home/apache-1.3.19--with-perl=/usr/local/bin/perl--enable-module=so |
Assuming that Perl's interpretation commands are installed in the/usr/local/bin directory, the Apache service is installed in the/home/apache-1.3.19 directory.
③ Installation
(2) Compiling and installing MOD_JK plug-ins
① Solution Package
$/USR/LOCAL/BIN/GZIP-DC Jakarta-tomcat-3.2.1-src.tar.gz|tar xf- |
② compilation
$ 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 |
Suppose 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 |
The installation is successful when the screen displays the following content.
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 Tomcat service
Use Superuser identity to unpack the compiled Tomcat 3.2.1 into the/home directory.
$ su #/usr/local/bin/gzip-dcjakarta-tomcat-3.2.1.tar.gz| (Cd/home;tar XF-) |
3. Parameter configuration
(1) Configure Apache Service
Use the VI command to open the Apache configuration file httpd.conf.
# cd/home/apache-1.3.19/conf # VI httpd.conf |
Add the following 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 according to the specific situation.
Jkloglevel warn Jkmount/*.jsp ajp13 jkmount/servlet/*.jsp |
Note: For other important but Tomcat-independent parameters (such as port and DocumentRoot, etc.) in this profile, refer to Apache documentation, which is not covered in this article.
(2) Configure Tomcat service
First, modify the Server.xml file. This assumes that the root directory of the Web page hosting Apache is/home/htdocs.
# cd/home/jakarta-tomcat-3.2.1/conf # VI Server.xml |
Then, in the Connectors section, embed the following content.
< Connector classname= "Org.apache.tomcat.service. Pooltcpconnector "> < Parameter name=" handler "value=" ORG.APACHE.TOMCAT.SERVICE.CONNECTOR.AJP 13ConnectionHandler "/> < Parameter name=" port "value=" 8009 "/> </connector> |
Next, embed the following in the Special WebApps section.
< context path= "" docbase= "/home/htdocs" debug= "0" > </context> |
Further 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 startup and shutdown command files.
# CD ... /bin # VI startup.sh |
Then embed the following in front of the "Basedir= ' dirname $" 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 before the "Basedir= ' dirname $" 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>
|
Finally, make a web browsing.
Open the browser to access the. jsp file: http://host name (or IP address)/test.jsp. If the screen display such as the figure shown in the content, indicating that the operation is normal, at this time, you can normally run JSP Dynamic Web page files.
Install on the Windows nt/2000 platform
This article takes the Windows 2000 platform for example.
(i) Application environment
The operating system uses Windows 2000, the application environment is Java 1.2.2 (assumed to be installed on c:jdk-1.2.2) and WinZip.
(ii) Download and installation of software packages
Installation on Windows NT2000 is simpler, the application software does not have to be recompiled, only downloaded packages that have been compiled on the site.
1. Download Address
The http://httpd.apache.org/dist/binaries/Windows32/can download the compiled new Apache package Apache_1.3.19-windows32-no_src-r2.msi.
Mod_jk.zip can be downloaded in http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.1/bin/Windows32/i386/.
Jakarta-tomcat-3.2.1.zip can be downloaded in http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.1/bin/.
2. Installation
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 Apache service configuration file httpd.conf
Note: This article only involves Tomcat-related parameters, and the rest of the parameter settings refer to Apache documentation.
First click on the "Start" * "program" * "Apache httpd Server" * "Configure Apache Server" * "Edit Configuration".
Then, embed the following in the "Dynamic Shared Object (DSO) Support" section.
LoadModule Jk_module Modules/mod_jk.dll |
Finally, add the following 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/* |
(2) Configure Tomcat service
To adjust the parameters of the Server.xml and workers.properties files, the reader can refer to the corresponding paragraphs in the UNIX section. But readers should note that for different levels of directories, UNIX is separated by "/" and Windows is separated by "". Edit the Startup.bat and Shutdown.bat files separately, embedding the following in the 2nd line 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
Test with the corresponding paragraphs in the UNIX section.
This article simply introduces the configuration and usage of the APACHE/JK method, and there are many parameters in Tomcat's configuration file (such as Server.xml) which can be adjusted according to the actual situation, which is not much introduced here. Interested readers can refer to the information in the configuration file or the relevant information on the website for further adjustment and testing.