首先,在发布网站之前,这个网站是已经做好了的。
这里只是介绍了一下载发布过程中可能遇到的问题以及解决的方法。
首先是添加Tomcat的虚拟主机
打开tomcat安装目录下conf/server.xml这个文件。在server.xml文档中找到
</Engine>
</Service>
接着在上面添加以下内容:
<Host name="qq.team12.com" debug="0" appBase="webapps" unpackWARs="true"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="qq" debug="0" reloadable="true" crossContext="true"/>
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs"
prefix="qq_team12_log." suffix=".txt"
timestamp="true"/>
</Host>
以上的内容就是在Tomcat的webapps目录下新建一个qq文件夹作为qq.team12.com这个域名的主目录
测试:
windows用户打开C:\WINDOWS\system32\drivers\etc的hosts这个文件,
linux用户打开/ect的hosts文件或者vim /ect/hosts
修改内容如下
127.0.0.1 localhost
127.0.0.1 qq.team12.com
接下来是进行Tomcat的首页设置
因为这个网站的首页是login.html,不是通常的index.html。所以需要修改Tomcat的首页。
打开tomcat安装目录下conf/web.xml这个文件
修改其中的下列内容
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
因为默认主页名称是login.html,修改如下:
<welcome-file-list>
<welcome-file>myjsp.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
把这两步结合到一起说就是:
修改server.xml中的docBase,相当于指定了默认的主目录。
修改web.xml,相当于是指定了默认的主页名
这样发布了还是在局域网内访问不到,因为Win7的防火墙机制是很强的。
接下来修改Win7的防火墙配置。
首先,打开防火墙
选择高级设置
选择入站规则
然后新建规则
规则类型选择端口,点击下一步
规则应用于TCP,使用于特定本地端口,80,点击下一步
操作选择允许连接,点击下一步
何时应用该规则,默认全选,点击下一步
为该规则起一个名称,点击完成
然后Tomcat发布的网站就能通过Win7的防火墙了。