域名解析与多域名绑定多个Tomcat项目
第一步、域名解析
1.登录阿里云的服务器地址:https://www.aliyun.com/ 新手礼包地址:https://s.click.taobao.com/as9o9Ox
2.点击控制台
3.点击域名----》解析
4.选择A记录
5.设置主机记录这儿可以设置多个比如手机站以M开头,博客站blog开头,默认是有WWW和@两项
6.输入服务器IP
7.这是我的解析
第二步、在Tomcat里设置解析的地址对应的项目
1.找到server.xml文件(tomcat7\conf\server.xml)
2.打开进行修改
修改1(端口修改默认8080改为80)
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
修改2(多域名绑定多项目)
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <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="m.luoruiyuan.cn" appBase="C:/Program Files/Tomcat/webapps/wap" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="."/> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <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是自带的,第二个Host是我们添加上去的【 name=要绑定的域名(如果你有多个域名指向这个项目可以加添alias节点示例地址:http://www.cnblogs.com/luoruiyuan/p/6054892.html) appBase=项目地址】
如果还要绑定多个域名就多添加几个Host就行了。