centos7 Apache+Tomcat
1. 安装tomca和httpd
[root@localhost ~]# yum -y install httpd jdk-8u131-linux-x64_.rpm httpd-devel gcc gcc-c++
[root@localhost ~]# tar zxf apache-tomcat-8.5.35.tar.gz
[root@localhost ~]# mv apache-tomcat-8.5.35 /opt/tomcat
[root@localhost ~]# /opt/tomcat/bin/startup.sh
[root@localhost ~]# systemctl start httpd
2. 安装jk模块
[root@localhost ~]# tar zxf tomcat-connectors-1.2.48-src.tar.gz
[root@localhost ~]# cd tomcat-connectors-1.2.48-src/native
[root@localhost native]# ./configure --with-apxs=/usr/bin/apxs
[root@localhost native]# make
[root@localhost native]# make install
[root@localhost native]# ls /etc/httpd/modules/mod_jk.so
/etc/httpd/modules/mod_jk.so
3. 创建测试页面
静态页面
[root@localhost native]# vim /var/www/html/index.html
[root@localhost native]# cat /var/www/html/index.html
<h1>JT_PAGE_HTTPD</h1>
动态页面
[root@localhost native]# vim /opt/tomcat/webapps/ROOT/test.jsp
[root@localhost native]# cat /opt/tomcat/webapps/ROOT/test.jsp
<h1>DT_PAGE_Tomcat</h1>
4. 配置jk模块,实现Apache整合tomcat
[root@localhost ~]# cd tomcat-connectors-1.2.48-src/conf/
[root@localhost ~]# cp httpd-jk.conf /etc/httpd/conf.d/
[root@localhost ~]# cp workers.properties /etc/httpd/conf/
[root@localhost ~]# vim /etc/httpd/conf/workers.properties
以下内容删除或者注释(参考下图)
worker.balancer.balance_workers=node2
worker.node2.reference=worker.template
worker.node2.host=localhost
worker.node2.port=8209
worker.node2.activation=A
修改port端口为8009(参考下图)
worker.balancer.balance_workers=node1
worker.node1.reference=worker.template
worker.node1.host=localhost
worker.node1.port=8009
[root@localhost ~]# vim /etc/httpd/conf.d/httpd-jk.conf
修改94行内容,去掉注释修改如下(参考下图)
JkMount /*.jsp balancer
5. 重启httpd
[root@localhost ~]# systemctl restart httpd
6. 测试
测试静态页面
测试动态页面访问