First, the system environment: CENTOS7 1406
Required Software: apache-tomcat-7.0.61.tar.gz
Httpd-2.2.29.tar.gz
Mod_jk-1.2.31-httpd-2.2.x.so
jdk-7u67-linux-x64.rpm
Download mod_jk corresponding httpd version http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/
Download jdkhttp://www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-download-346242.html
Second, the installation of HTTPD services
#tar XZVF httpd-2.2.29.tar.gz #cd httpd-2.2.29 #. ./configure--prefix=/usr/local/apache2-enable-so-enable-rewrite # make && make install
Iii. installation and configuration of the JDK development environment
# RPM-IVH jdk-7u67-linux-x64.rpm
Modify the/etc/profile file to add the variable settings required for the Java development environment.
Export Java_home=/usr/java/jdk1.7.0_67export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _ Home/lib/tools.jarexport path= $PATH: $JAVA _home/bin
Save exit
# Source/etc/profile
Verify:
#java-version
Tip: Java Version "1.7.0_67" Java (tm) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot (tm) 64-bit Server VM (build 24. 65-B04, Mixed mode)
Iv. installation of Tomcat
Tar zxvf apache-tomcat-7.0.61.tar.gz-c/usr/local/ln-sf/usr/local/apache-tomcat-7.0.61//usr/local/tomcat Ln -sf/usr/local/tomcat/bin/startup.sh/usr/bin/tomcat-on Ln-sf/usr/local/tomcat/bin/shutdown.sh/usr/bin/tomcat-off
Modify the/etc/profile file to set the variable catalina_home that the Tomcat service needs to use.
Export $CATALINA _home=/usr/local/tomat exportclasspath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar:$ Catalina_home/lib/servlet-api.jar
Modify the Tomcat-users.xml file to add the Administrator account "Tomcat" settings.
]# vim/usr/local/tomcat/conf/tomcat-users.xml <?xml version= ' 1.0 ' encoding= ' utf-8 '?> <tomcat-users> < Role rolename= "Manager-gui"/> <role rolename= "Admin-gui"/> <user username= "Tomcat" password= "Tomcat" roles= "Manager-gui,admin-gui"/> </tomcat-users>
Start:
# tomcat-onusing Catalina_base:/usr/local/tomcatusing catalina_home:/usr/local/tomcatusing CATALINA_TMPDIR:/usr/lo Cal/tomcat/tempusing jre_home:/usr/java/jdk1.7.0_67using CLASSPATH:/USR/LOCAL/TOMCAT/BIN/BOOTSTRAP.JAR:/USR /local/tomcat/bin/tomcat-juli.jartomcat started.
]# netstat -anpt | grep javatcp6 0 0 127.0.0.1:8005 :::*
LISTEN 18313/java tcp6 0 0::: 8009:::* LISTEN 18313/JAVATCP6 0 0::: 8080:::* LISTEN 18313/java
V. Connecting the Tomcat service to the Aptech service
Tomcat can run on its own as a Web server, but Tomcat's web features are far less powerful than Apache. In real-world applications, Apache and Tomcat are integrated with MOD_JDK connectors (connectors). The work of invoking the Tomcat service is done by Apache, and the user only needs to access the Apache service.
(1) Install the MOD_JDK module.
]# CP mod_jk-1.2.31-httpd-2.2.x.so/usr/local/apache2/modules/
(2) Adjust the configuration of Apache service, Tomcat service, and restart Tomcat, httpd service. Modify the http.conf configuration file to add the JDK invocation configuration.
]# vi/usr/local/apache2/conf/httpd.conf
(3) in the Apache Conf directory to create a new two files, mod_jk.conf and workers.properties files, mod_jk.conf content is JK's configuration file, including loading module and log information as well as specifying the resolution of the worker and directory, work Ers.properties is a configuration file for Tomcat wokers.
(4) Add the following in the mod_jk.conf (mod_jk.conf file is easy to manage without having to write the configuration in httpd.conf)
#加载jk模块, the name should correspond.
LoadModule Jk_module modules/mod_jk-1.2.28-httpd-2.2.x.so
# Load the workers.properties file you just created
Jkworkersfile conf/workers.properties
# JK Log File
Jklogfile Logs/mod_jk.log
# JK Log level, parameters are [Debug/error/info]
Jkshmfile LOGS/MOD_JK.SHM Jkloglevel Info
# JK Log Data format
Jklogstampformat "[%a%b%d%h:%m:%s%Y]"
# JK's some configuration options indicate to send SSL KEY SIZE,
Jkoptions +forwardkeysize +forwarduricompat-forwarddirectories
# JK Request Log format
Jkrequestlogformat "%w%V%T"
#JSP do servlet file is referred to Tomcat for processing
jkmount/servlet/* ajp13 jkmount/*.jsp ajp13 jkmount/*.do ajp13
# Jkmount means using Tomcat to parse, Jkunmount is the opposite
# typically JSP and servlet programs are handled by Tomcat, and still files are processed by Apache #JkAutoAlias/usr/local/apache2/htdocs*
#该文件夹下所有的静态文件自动交由Apache处理 jkmount/test/servlet/* ajp13 (5) Add a Tomcat profile and create a Web App directory link
]# vi/usr/local/apache2/conf/workers.properties worker.list=work1 worker.work1.port=8009 worker.work1.host=xfsbuy WORKER.WORK1.TYPE=AJP13 worker.work1.lbfactor=1
]# cd/usr/local/tomcat]# mv WebApps webapps.bak]# Ln-sf/usr/local/apache2/htdocs WebApps
(6) Restart Apache and Tomcat services.
]# Tomcat-off] #tomcat-on]#/usr/local/apache2/bin/apachectl Restart
(7) test the JSP test page that created the display system time.
~]# mkdir/usr/local/apache2/htdocs/webs/~]# vi/usr/local/apache2/htdocs/webs/showtime.jsp <% @page language= " Java "import=" java.util.* "%>now,the time&date is: <%out.println (new Date ());%>
Test: http://172.16.0.13/webs/showtime.jsp, the current system time should be displayed in the Web page
Reference: http://www.linuxidc.com/Linux/2012-11/74474.htm
http://blog.csdn.net/v1v1wang/article/details/6128565
This article is from the "Starseven" blog, make sure to keep this source http://lcpljc.blog.51cto.com/200989/1633237
Test CENTOS7 on Apache+tomcat environment construction