Build an Apache + Tomcat environment on centos7
I. System Environment: Centos7 1406
Required software:
apache-tomcat-7.0.61.tar.gzhttpd-2.2.29.tar.gzmod_jk-1.2.31-httpd-2.2.x.sojdk-7u67-linux-x64.rpm
Download mod_jk httpd version http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/
Download jdkhttp: // www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-download-0000242.html
Ii. Install the httpd service
#tarxzvfhttpd-2.2.29.tar.gz
#cdhttpd-2.2.29
#./configure--prefix=/usr/local/apache2-enable-so-enable-rewrite
#make&&makeinstall
3. install and configure the jdk Development Environment
#rpm-ivhjdk-7u67-linux-x64.rpm
Modify the/etc/profile file and add variable settings required by the JAVA development environment.
exportJAVA_HOME=/usr/java/jdk1.7.0_67exportCLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexportPATH=$PATH:$JAVA_HOME/bin
Save and exit
#source/etc/profile
Verification:
#java-version
Tip:
javaversion"1.7.0_67"Java(TM)SERuntimeEnvironment(build1.7.0_67-b01)JavaHotSpot(TM)64-BitServerVM(build24.65-b04,mixedmode)
4. install tomcat
tar
zxvfapache-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
Note: Quick Start
ln
-sf
/usr/local/tomcat/bin/shutdown
.sh
/usr/bin/tomcat-off
Quick Close
Modify the/etc/profile file and set the variable CATALINA_HOME to be used by Tomcat.
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
<?xmlversion=
'1.0'
encoding=
'utf-8'
?>
<tomcat-
users
>
<rolerolename=
"manager-gui"
/>
<rolerolename=
"admin-gui"
/>
<userusername=
"tomcat"
password=
"tomcat"
roles=
"manager-gui,admin-gui"
/>
<
/tomcat-users
>
Start:
#tomcat-on
UsingCATALINA_BASE:
/usr/local/tomcat
UsingCATALINA_HOME:
/usr/local/tomcat
UsingCATALINA_TMPDIR:
/usr/local/tomcat/temp
UsingJRE_HOME:
/usr/java/jdk1
.7.0_67
UsingCLASSPATH:
/usr/local/tomcat/bin/bootstrap
.jar:
/usr/local/tomcat/bin/tomcat-juli
.jar
Tomcatstarted.
]
#netstat-anpt|grepjava
tcp600127.0.0.1:8005:::*
LISTEN18313/javatcp600:::8009:::*LISTEN18313/javatcp600:::8080:::*LISTEN18313/java
5. Connect the Tomcat service to the Aptech Service
Tomcat can run independently as a Web server, but Tomcat's Web functions are not as powerful as Apache. In actual use, Apache and Tomcat are integrated through the mod_jdk connector (Connectors.
Apache is used to call the Tomcat service, but you only need to access the Apache service.
(1) install the mod_jdk module.
]
#cpmod_jk-1.2.31-httpd-2.2.x.so/usr/local/apache2/modules/
(2) Adjust the configuration of Apache and Tomcat services, and restart tomcat and httpd services. Modify the http. conf configuration file and add the jdk call configuration.
]
#vi/usr/local/apache2/conf/httpd.conf
(3) create two new files in the conf directory of Apache.
Mod_jk.conf and workers. properties files.
The content of mod_jk.conf is the jk configuration file, including the loading module and log information, as well as the designated parser and directory.
Workers. properties is the configuration file of Tomcat wokers.
(4) Add the following content to mod_jk.conf (the mod_jk.conf file is convenient for management, and you do not need to write the configuration in httpd. conf)
# Load jk module. The name must correspond
LoadModulejk_modulemodules/mod_jk-1.2.28-httpd-2.2.x.so
# Load the newly created workers. properties File
JkWorkersFileconf/workers.properties
# Jk log file
JkLogFilelogs/mod_jk.log
# Jk log level. The parameters include [debug/error/info]
JkShmFilelogs/mod_jk.shmJkLogLevelinfo
# Jk log data format
JkLogStampFormat"[%a%b%d%H:%M:%S%Y]"
# Some configuration options of Jk: indicate to send ssl key size,
JkOptions+ForwardKeySize+ForwardURICompat-ForwardDirectories
# Jk request log format
JkRequestLogFormat"%w%V%T"
# Submit the JSP do Servlet File to Tomcat for processing
JkMount/servlet/*ajp13JkMount/*.jspajp13JkMount/*.doajp13
# JkMount indicates that Tomcat is used for parsing, while JkUnMount indicates that the opposite is true.
# Generally, jsp and servlet programs can be processed by tomcat, and static file images are still processed by Apache.
#JkAutoAlias/usr/local/apache2/htdocs*
# All static files in this folder are automatically processed by Apache.
(5) Add the tomcat configuration file and create a Web application 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
]
#mvwebappswebapps.bak
]
#ln-sf/usr/local/apache2/htdocswebapps
(6) Restart apache and tomcat services.
]
#tomcat-off
]
#tomcat-on
]
#/usr/local/apache2/bin/apachectlrestart
(7) Test the JSP test webpage that shows the system time when the system is created.
~]
#mkdir/usr/local/apache2/htdocs/webs/
~]
#vi/usr/local/apache2/htdocs/webs/showtime.jsp
<%@pagelanguage=
"java"
import
=
"java.util.*"
%>
Now,the
time
&
date
is:<%out.println(newDate());%>
Test: http: // 172.16.0.13/webs/showtime. jsp. The current system time should be displayed on the webpage.
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, please be sure to keep this source http://lcpljc.blog.51cto.com/200989/1633237