标签:col host tty font enable rdk oca ima add-port
说明:这里是Linux服务综合搭建文章的一部分,本文可以作为单独搭建Tomcat并整合httpd的参考。
如果需要查看相关软件版本和主机配置要求,请根据目录自行查看。
Linux服务综合搭建的文章目录
1 [root@rhel7 ~]# yum install httpd 2 3 [root@rhel7 ~]# systemctl enable httpd && systemctl restart httpd 4 5 [root@rhel7 ~]# firewall-cmd --permanent --add-service=http && firewall-cmd --reload
1 [root@rhel7 www]# echo ‘172.25.0.55:/nfsshare/web/ /var/www/html nfs defaults 0 0‘ >>/etc/fstab
挂载:
安装过程:下载--解压--做链接--启动
下载软件包
1 [root@rhel7 ~]#mkdir /usr/local/tomcat8 2 [root@rhel7 ~]# tar xvf apache-tomcat-8.5.38.tar -C /usr/local/tomcat8
1 [root@rhel7 bin]# ln -s /usr/local/tomcat8/apache-tomcat-8.5.38/bin/startup.sh /usr/sbin/start-tomcat8 2 [root@rhel7 bin]# ln -s /usr/local/tomcat8/apache-tomcat-8.5.38/bin/shutdown.sh /usr/sbin/shutdown-tomcat8
1 [root@rhel7 bin]# firewall-cmd --permanent --add-port=8080/tcp --add-port=8080/udp 2 [root@rhel7 bin]# firewall-cmd --reload
注意:网站域名为tomcat.mei.com
Connector主要负责处理与客户端的通信。Connector的实例用于监听端口,接受来自客户端的请求并将请求转交给Engine处理。同时将来自Engine的答复返回给客户端
注意:这里我在foundation上已经准备好了tomcat-connectors-1.2.40-src.tar.gz的软件包
可以到官网下载或者我的网盘共享中下载或者其它第三方下载
建议不要官网https://tomcat.apache.org/download-connectors.cgi
官网下载很慢,可以到下面的网站搜索下载
1 [root@foundation ~]# yum install httpd-devel
1 [root@rhel7 ~]# wget http://pakg.mei.com/packages/tomcat-connectors-1.2.40-src.tar.gz 2 [root@rhel7 ~]# mv tomcat-connectors-1.2.40-src.tar.gz /usr/local/src/ 3 [root@rhel7 src]# tar xvf tomcat-connectors-1.2.40-src.tar.gz
1 [root@rhel7 src]# cd tomcat-connectors-1.2.40-src/native/ 2 [root@rhel7 native]# which apxs 3 /bin/apxs
注意:编译要依赖apxs还有JAVA环境
1 [root@rhel7 native]# ./configure --with-apxs=/bin/apxs 2 [root@rhel7 native]# make
1 [root@rhel7 apache-2.0]# cp mod_jk.so /etc/httpd/modules/
JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories JkRequestLogFormat "%w %V %T" JkMount /servlet/* worker1 JkMount /*.jsp worker1
worker.list=worker1 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.lbfactor=50 worker.worker1.cachesize=10 worker.worker1.cache_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.socket_timeout=300
Include conf/mod_jk.conf LoadModule jk_module modules/mod_jk.so ServerName tomcat.mei.com:80
index.jsp中的内容
<%@page import="java.util.Date"%> <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> 当前时间是: <% //out.print(new java.util.Date().toLocaleString());toLocaleString()方法早已经过时了, //由DateFormat.format(Date date)取代。 //out.print(new java.util.Date().toLocaleString()); out.print(new java.util.Date().toString()); out.print(new java.util.Date()); %> </body> </html>
[root@foundation ~]# curl http://tomcat.mei.com <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> 当前时间是: Sun Jul 07 17:55:45 CST 2019Sun Jul 07 17:55:45 CST 2019 </body> </html> [root@foundation ~]#
最后希望大家提意见、转发、评论和交流!!!
JAVA web环境搭建(使用Tomcat8整合httpd)
标签:col host tty font enable rdk oca ima add-port
原文地址:https://www.cnblogs.com/meizy/p/tomcat_httpd.html