The combination of apache and tomcat is still quite large. To use jsp, most companies adopt apache + tomcat:
I. System Version: Centos 5.3 64-bit System
Nginx version: httpd-2.2.13.tar.bz2
Jdk version: 1.6.0 _ 18_64
Tomcat version: Apache Tomcat/6.0.30
Other similar versions are supported! The package required for service installation is as follows: Download the integration section of this website:
Download jdk from the following website: Select jdk of your system.
Https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewFilteredProducts-SingleVariationTypeFilter
Download Apache and Tomcat to/usr/src]
Cd/usr/src & wget http://blog.mgcrazy.com/download/?httpd-2.2.13.tar.bz2,apache-tomcat-6.0.30.tar.gz}
Ii. install Apache
cd /usr/src && tar -jxvf httpd-2.2.13.tar.bz2 && cd httpd-2.2.13/srclib/apr &&./configure --prefix=/usr/local/apr &&make &&make install &&cd ../apr-util/ && ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr &&make&&make install && cd ../../ && ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --with-mpm=worker --enable-deflate --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-proxy --enable-proxy-ajp --enable-proxy-balancer --enable-proxy-http --enable-rewrite --enable-charset-lite --disable-ipv6 --disable-dav --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
You can directly copy and install apache. [Note * install mod_proxy to process the Tomcat jsp page module. Install apr and apr-util to increase Tomcat processing performance. Of course, you can also use mod_jk, if it is mod_jk approach, you can refer to this article: http://bbs.linuxtone.org/thread-1195-1-1.html] III. Tomcat installation configuration: download the required package to the/usr/src directory; first install jdk: chmod o + x jdk *&&. /jdk *; the package prompts you to press the Enter key. You can install the package as prompted. After decompression, the jdk1.6.0 _ 18 folder is generated in the current directory.
Mkdir-p/usr/java & mv jdk1.6.0 _ 18/usr/java/
Add the following statement to the end of vi/etc/profile:
Export JAVA_HOME =/usr/java/jdk1.6.0 _ 18
Export CLASSPATH = $ CLASSPATH: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib
Export PATH = $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin: $ PATH: $ HOMR/bin
Source/etc/profile // make the environment variable take effect immediately
Java-version // check the java version. if the version is 1.6.0 _ 18 and 64-bit, the installation is successful!
Java HotSpot (TM) 64-Bit Server VM (build 16.0-b10, mixed mode)
Apache-tomcat-6.0.30.tar.gz cd/usr/src & tar xzf
Decompress the package and execute:
Mv apache-tomcat-6.0.30/usr/local/tomcat_1 & cp/usr/local/tomcat_1/usr/local/tomcat_2-r
Set tomcat java Variables
Cd/usr/local/tomcat_1/bin/& vi setenv. sh create a setenv. sh script file and add the following statement:
JAVA_HOME =/usr/java/jdk1.6.0 _ 18
JAVA_JRE =/usr/java/jdk1.6.0 _ 18/jre
And copy the setenv. sh file to atat_2/bin:
Cp-p/usr/local/tomcat_1/bin/setenv. sh/usr/local/tomcat_2/bin!
Save and exit
Check whether the *. sh file in the bin directory of the two tomcat servers has executable permissions. If not, go to the corresponding directory and execute chmod o + x *. sh!
Create different directories for the two tomcat servers: mkdir-p/usr/webapps/{www_1, www_2}
Modify the Tomcat_1 server. xml file as follows:
<Enginename = "Catalina" defaultHost = "localhost" jvmRoute = "tomcat1">
Add
<Contextpath = "" docBase = "/usr/webapps/www_1" reloadable = "true"/>
In the same way, set tomcat_2:
<Enginename = "Catalina" defaultHost = "localhost" jvmRoute = "tomcat2">
<Contextpath = "" docBase = "/usr/webapps/www_2" reloadable = "true"/>
Set the jvmroute names of the two tomcat servers to tomcat1 and tomcat2, which will be used in the apache configuration file later!
4. Configure the Apache Virtual Host to modify vhosts. conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin wgkgood@163.com
DocumentRoot "/usr/webapps/www"
ServerName 192.168.2.79
<Directory "/usr/webapps/www ">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
ProxyRequests Off
RewriteEngine On
ProxyPreserveHost On
RewriteRule ^$ balancer://wwwCluster/ [P,L,NC]
RewriteRule ^/(.*)$ balancer://wwwCluster/$1 [P,L,NC]
<Proxy balancer://wwwCluster>
BalancerMember ajp://localhost:8411 route=tomcat1
BalancerMember ajp://localhost:8412 route=tomcat2
</Proxy>
</VirtualHost>
As shown above, ports 8411 and 8412 are the AJP ports of two tomcat servers and can be modified as needed. In this case, all configurations are complete! Start apache OK! Create an index. jsp file in both tomcat release directories and enter the following content:
<body>
<%=new java.util.Date()
%>
</body>
The second machine writes the following content:
<body>
<%=new java.util.Date()
%>
</body>
Then, access http: // 192.168.2.79. Different pages are displayed, that is, the content of two tomcat servers.
This article from the "Wu guangke-Focus on automated O & M" blog, please be sure to keep this source http://wgkgood.blog.51cto.com/1192594/558220