1. Download
Apache--yum Install Httpd-y
Tomcat DOWNLOAD Link--http://tomcat.apache.org/
MOD_JK Download Link--http://tomcat.apache.org/download-connectors.cgi
This paper takes httpd-2.2.15+tomcat-8.5.14+mod_jk-1.2.42 as an example
HTTPd through the Yum installation configuration is all the default (due to the last step of verification I use PHP to verify so many loaded PHP, the simplest lamp configuration can refer to the link), Tomcat direct download pressure is not modified configuration, installation directory/usr/myapp/ apache-tomcat-8.5.14/, there is not much to be said about the two.
2.MOD_JK installation Configuration
First of all to understand "APACHE+TOMCAT+MOD_JK configuration" exactly what to do, one is to build MOD_JK module, the second is to load MOD_JK in Apache and configure it, three is in Tomcat to modify the configuration so that it can accept mod_jk forwarding.
2.1 Compiling build MOD_JK module
Compile the build mod_jk.so, and then copy it to the HTTPD load module default directory/etc/httpd/modules
Yum Install httpd-devel-y #编译生成apache扩展依赖apxs, if not installed first
wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-connectors/jk/ tomcat-connectors-1.2.42-src.tar.gztar -zxf tomcat-connectors-1.2. -src. Tar . GZCD Tomcat-connectors-1.2. -src/native/. /configure--with-apxs=/usr/sbin/apxsmakecp ./apache-2.0/mod_jk.so/ etc/httpd/modules/
2.2 Load MOD_JK and configure it in Apache
cd/etc/httpd/conf.d/Cat> mod_jk.conf <<eof# Load mod_jk moduleloadmodule jk_module modules/mod_jk.so# ADD The module (activate this lne forApache1.3) # addmodule mod_jk.c# Where toFindWorkers.propertiesjkworkersfileconf.d/workers.properties# Where to put JK shared Memoryjkshmfilelog/httpd/mod_jk.shm# Where to put JK Logsjklogfilelog/httpd/mod_jk.log# Set The JK log level [Debug/error/Info]jkloglevelInfo# Send Requests forContext/examples to worker named Worker1jkmount/examples/*tomcat1eof
LoadModule line--load MOD_JK module
Jkworkersfile line--worker The path where the connection configuration file is located, the file needs to be created by itself. The path inherits the ServerRoot, so the full path is/etc/httpd/conf.d/workers.properties, and of course it can be specified as any other location using the in-place path. Behind several configurations with this.
Jkshmfile line--MOD_JK shared memory files in place, files do not need to be created by themselves
Jklogfile line--MOD_JK log storage location, files do not need to create their own
Jkloglevel Line--MOD_JK Logging level
Jkmount Line-/examples/The beginning of the instructions are transferred to TOMCAT1 processing
Jkworkersfile Line We specify the connection profile path for the worker, which is where the worker is Tomcat. So we're going to create the/etc/httpd/conf.d/workers.properties file and write the Tomcat connection information
cd/etc/httpd/conf.dcat > Workers.properties <<1 real worker using Ajp13worker.list= for worker1 (ajp13) worker.tomcat1.type= Ajp13worker.tomcat1.host=localhostworker.tomcat1.port=8009EOF
Worker.list line--worker list. If more than one is separated by commas (half-width).
Worker.tomcat1.type line-the protocol and version used to connect the TOMCAT1. If you configure another worker, change the TOMCAT1 to the appropriate worker name.
Worker.tomcat1.host the domain name (including/etc/hosts) or IP address of the--TOMCAT1 line. If you configure another worker, change the TOMCAT1 to the appropriate worker name.
Worker.tomcat1.port Line--tomcat AJP port, default 8009. (The meaning of Tomcat listening on Port 8009 is here)
2.3 Tomcat Configuration Jvmroute
In Workers.properties we have specified woker named TOMCAT1, but it is not known on the Tomcat side that TOMCAT1 refers to it. Just like someone gave you a code 9527 did not inform you, and then to your home to tell you to find 9527, you do not know is to find you the same.
We need to find the engine tag in $catalina_home/conf/server.xml and configure its Jvmroute property value to be the worker name (this is TOMCAT1)
2.4 Restart Apache and Tomcat to make the configuration effective
Service httpd Restart
cd/usr/myapp/apache-tomcat-8.5. /bin #根据自己tomcat目录修改路径. /shutdown. SH . /startup. SH
3 Functional Implementation Verification
Verify that Apache is functional-Create classic phpinfo.php and access, if normal display means that Apache's original function is normal.
Verify that the Tomcat forwarding is successful-the top mod_jk.conf we configured/examples/the beginning of the instructions are transferred to TOMCAT1 processing, if we visit http://127.0.0.1/examples/ The result is that Tomcat displays the contents of its Webapps/examples directory stating that the forwarding was successful.
3.1 Verifying that Apache is functioning properly
cd/var/www/html #进入apache默认主目录 cat > phpinfo.php << EOF<? PHP phpinfo ()?>EOF
3.2 Verifying that Tomcat forwarding was successful
Reference:
Http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
Http://tomcat.apache.org/connectors-doc/common_howto/loadbalancers.html
Https://stackoverflow.com/questions/3666649/apache-httpd-2-2-x-mod-jk-1-2-30-tomcat-6-error-could-not-find-worker-with
APACHE+TOMCAT+MOD_JK Configuration Tutorial