tomcat8版本实现虚拟主机
vim /etc/hosts
192.168.30.21 www.crushlinux.com
192.168.30.21 www.cloud.com
[root@localhost ~]# cd /usr/local/tomcat8/conf
[root@localhost conf]# cp server.xml server.xml_(date +%F)
vim /usr/local/tomcat8/conf/server.xml
修改下面的
<Host name="www.crushlinux.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="/web/crushlinux" path="" reloadable="flase" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="www.cloud.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="/web/cloud" path="" reloadable="flase" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
mkdir -pv /web/{crushlinux,cloud}
vim /web/crushlinux/index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>JSP crushlinux page</title>
</head>
<body>
<% out.println("Welocome to test site,http://www.crushlinux.com");%>
</body>
</html>
~
vim /web/cloud/index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>JSP cloud page</title>
</head>
<body>
<% out.println("Welocome to test site,http://www.cloud.com");%>
</body>
</html>
~
/usr/local/tomcat8/bin/shutdown.sh
/usr/local/tomcat8/bin/startup.sh
自带浏览器访问域名:http://www.crushlinux.com:8080
自带浏览器访问域名:http://www.cloud.com:8080