大家好,又见面了,我是你们的朋友全栈君。
虚拟主机用在一台物理机上搭建多个web站点,且互不影响
基于域名的主机
- 根据来访问的域名解析对应每个不同的web站点
- 配置域名与ip的映射管理(hosts)
在host文件中添加对应的ip域名17,19vim /etc/hosts 192.168.200.19 www.linuxxu.com 192.168.200.18 www.cloud.com
- 修改server.xml创建host模块对应域名
vim /usr/local/tomcat8/conf/server.xml <Host name="www.linuxxu.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context docBase="/web/linuxxu" path="" reloadable="flase"> </Context> <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.whml.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context docBase="/web/whml" path="" reloadable="flase"> </Context> <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/{linuxxu,cloud} #对应创建index.jsp文件 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
- 测试页面
基于端口的主机
- 修改server.xml配置文件
<Service name="Catalina"> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="www.jalja1.org" appBase="E:/学习/activeMq/app1" unpackWARs="true" autoDeploy="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> <Service name="Catalina2"> <Connector port="8888" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina2" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="www.jalja1.org" appBase="E:/学习/activeMq/app2" unpackWARs="true" autoDeploy="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service>
基于ip的主机
- 配置多个子网接口,一一对应rever.xml里的web站点
Tomcat多实例配置
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/155101.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...