Preparations for Tomcat and Apache Integration
Note:This environment continues after Apache compilation is complete.
)
JDK
JDK is an essential software for installation and testing in the tomcat runtime environment. Because tomcat is only a Servlet/JSP Container, the underlying operations must be completed by JDK)
[root@chenyi software]# chmod a+x jdk-6u7-linux-i586.bin [root@chenyi software]# ./jdk-6u7-linux-i586.bin
Set environment variables. Tomcat will find the jdk installation path at startup)
[root@chenyi software]# vi /etc/profile.d/java.sh export JAVA_HOME=/software/jdk1.6.0_07 export JRE_HOME=$JAVA_HOME/jre export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
[root@chenyi software]# chmod 755 /etc/profile.d/java.sh [root@chenyi software]# . /etc/profile
You can test whether java works normally.
[root@chenyi software]# java -versionjava version "1.6.0_07"Java(TM) SE Runtime Environment (build 1.6.0_07-b06)Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
Test JAVA program
[root@chenyi software]# vi test.javapublic class test { public static void main(String args[]) { System.out.println("Hello World!"); }}[root@chenyi software]# javac test.java [root@chenyi software]# java testHello World!
To install Tomcat, you only need to decompress the package and change the name to a proper place to complete the installation)
[root@chenyi lamp]# tar zxf apache-tomcat-6.0.14.tar.gz[root@chenyi lamp]# mv apache-tomcat-6.0.14 /software/tomcat
Compile and generate mod_jk. Here, we want to use the mod_jk connector more flexibly, so we need to specify the apache apxs path for compiling the required JK module in the source code mode ))
[root@chenyi lamp]# tar zxf jakarta-tomcat-connectors-1.2.15-src.tar.gz [root@chenyi lamp]# cd jakarta-tomcat-connectors-1.2.15-src[root@chenyi jakarta-tomcat-connectors-1.2.15-src]# ./configure --with-apxs=/software/apache2/bin/apxs && make && make install[root@chenyi native]# ls /software/apache2/modules/mod_jk.so /software/apache2/modules/mod_jk.so
Create mod_jk.conf and pay attention to my path)
[Root @ chenyi httpd] # vi mod_jk.conf loadModule jk_module "/software/apache2/modules/mod_jk.so" # specify mod_jk.soJkWorkersFile "/etc/httpd/workers. properties "# setting JkLogFile for JK connector properties"/software/tomcat/logs/mod_jk.log "JkLogLevel emergServerName localhostJkmount /*. jsp ajp13
Create workers. properties
Workers. tomcat_home =/software/tomcatworkers. java_home =/software/jdk1.6.0 _ 07 ps =/workers. list = ajp13 # worker. list is used to define the Workers list. When apache is started, workers. properties will be initialized in worker as a plug-in. workers in the list. Workers. ajp13.port = 8009 # tomcat worker host listening port. By default, tomcat uses the 8009workers port in the ajp13 protocol. ajp13.host = 127.0.0.1 # tomcat worker host address for listening to ajp13 requests. ajp13.type = ajp13 # define a worker named "ajp13". It uses the ajp13 protocol to communicate with the tomcat process workers. ajp13.lbfactor = 1 # When tomcat is used as a server Load balancer instance, this attribute is used, indicating the Server Load balancer weight of this tomcat worker node.
Configure Apache
[root@chenyi httpd]#vi httpd.conf
Add the following statement
Include /etc/httpd/mod_jk.conf
Restart Apache and Tomcat after saving AND EXITING
[root@chenyi ~]# /software/apache2/bin/apachectl stop[root@chenyi ~]# /software/apache2/bin/apachectl start[root@chenyi ~]# /software/tomcat/bin/shutdown.sh Using CATALINA_BASE: /software/tomcatUsing CATALINA_HOME: /software/tomcatUsing CATALINA_TMPDIR: /software/tomcat/tempUsing JRE_HOME: /software/jdk1.6.0_07/jre[root@chenyi ~]# /software/tomcat/bin/startup.sh Using CATALINA_BASE: /software/tomcatUsing CATALINA_HOME: /software/tomcatUsing CATALINA_TMPDIR: /software/tomcat/tempUsing JRE_HOME: /software/jdk1.6.0_07/jre
View service status through netstat
[root@chenyi ~]# netstat -pant | grep 80tcp 0 0 127.0.0.1:42442 127.0.0.1:8009 TIME_WAIT - tcp 0 0 127.0.0.1:42441 127.0.0.1:8009 TIME_WAIT - tcp 0 0 127.0.0.1:42438 127.0.0.1:8009 TIME_WAIT - tcp 0 0 127.0.0.1:42439 127.0.0.1:8009 TIME_WAIT - tcp 0 0 127.0.0.1:42446 127.0.0.1:8009 TIME_WAIT - tcp 0 0 127.0.0.1:42440 127.0.0.1:8009 TIME_WAIT - tcp 0 0 127.0.0.1:42437 127.0.0.1:8009 TIME_WAIT - tcp 0 0 127.0.0.1:42443 127.0.0.1:8009 TIME_WAIT - tcp 0 0 127.0.0.1:42445 127.0.0.1:8009 TIME_WAIT - tcp 0 0 :::8080 :::* LISTEN 4434/java tcp 0 0 :::80 :::* LISTEN 4399/httpd tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 4434/java tcp 0 0 :::8009 :::* LISTEN 4434/java tcp 0 0 ::ffff:127.0.0.1:58570 ::ffff:127.0.0.1:8005 TIME_WAIT - tcp 0 0 ::ffff:127.0.0.1:43053 ::ffff:127.0.0.1:8080 TIME_WAIT -
Access through http: // IP: 8080 for testing650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/1930245605-0.jpg "alt =" "border =" 0 "/>
Set Tomcat Login Password
[Root @ chenyi ~] # Vi/software/tomcat/conf/tomcat-users.xml? Xml version = '1. 0' encoding = 'utf-8'?> <Tomcat-users> <role rolename = "manager"/> <role rolename = "admin"/> <user username = "itchenyi" password = "123456" roles = "manager, admin "/> # newly added </tomcat-users>
Write a simple jsp page for testing[Root @ chenyi ~] # Vi/software/tomcat/webapps/ROOT/test. jsp
<%@ page language="java" %><%@ page import="java.util.*" %>
Access650) this. width = 650; "src =" ../attachment/201304/155222570 .jpg" alt = "" border = "0"/> tomcatjsp Test
QQ chat group: 41405569
This article from the "IT Chen Yi" blog, please be sure to keep this source http://itchenyi.blog.51cto.com/4745638/1169267