Apache+Tomcat动静分离
1,装jdk环境
[root@localhost ~]# rpm -ivh jdk-8u131-linux-x64_.rpm
[root@localhost ~]# java -version
java version “1.8.0_131”
Java™ SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot™ 64-Bit Server VM (build 25.131-b11, mixed mode)
2,解压Tomcat包并建立相关目录
[root@localhost ~]# tar -zxf apache-tomcat-8.5.35.tar.gz
[root@localhost ~]# mkdir /opt/tomcat
[root@localhost ~]# mv apache-tomcat-8.5.35 /opt/tomcat/
[root@localhost ~]#./opt/tomcat/apache-tomcat-8.5.35/bin/startup.sh
3,安装相关服务
yum -y install httpd httpd-devel gcc gcc-c++
4,下载mod_jk包并配置
mod_jk安装包
安装mod_jk
[root@localhost ~]# tar -zxf tomcat-connectors-1.2.46-src.tar.gz
[root@localhost native]# pwd
/root/tomcat-connectors-1.2.46-src/native
[root@localhost native]# ./configure --with-apxs=/usr/bin/apxs #centos6是sbin
[root@localhost native]# make && make install
[root@localhost native]# ls /etc/httpd/modules/mod_jk.so
/etc/httpd/modules/mod_jk.so
[root@localhost conf]# pwd
/root/tomcat-connectors-1.2.46-src/conf
[root@localhost conf]# cp workers.properties /etc/httpd/conf
[root@localhost conf]# cat /etc/httpd/conf/workers.properties
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=192.168.88.88
worker.worker1.port=8009
[root@localhost conf]# cat /etc/httpd/conf/httpd.conf | grep "index.jsp"
DirectoryIndex index.jsp index.html
LoadModule jk_module modules/mod_jk.so #最后一行写 加载mod_jk.so模块
JkWorkersFile /etc/httpd/conf/workers.properties #指定mod_jk模块的配置文件
JkMount /*.jsp worker1 #将所有以.jsp结尾的请求转发给worker1
[root@localhost ~]# systemctl restart httpd
网页测试