[svc]tomcat在win+eclipse上部署/及虚拟主机配置/http302
tomcat也可以称为catalina
catalina_home就是tomcat安装路径:D:\Program Files\apache-tomcat-8.0.36\bin
windows下安装tomcat:
设置JAVA_HOME:

系统环境变量jdk的path可以不配,(系统变量)里一定要有JAVA_HOME变量,tomcat要调用
检查:

其次解压tomcat.tar.gz

tomcat安装完毕.
tomcat的启动关闭:
D:\Program Files\apache-tomcat-8.0.36\bin startup.bat ->启动后会一直有tomcat启动cmd窗悬浮. shutdown.bat

访问主页文件: D:\Program Files\apache-tomcat-8.0.36\webapps\ROOT

放开发写的程序: D:\Program Files\apache-tomcat-8.0.36\webapps 放tomcat根据程序生成的东西: D:\Program Files\apache-tomcat-8.0.36\work

tomcat也可以称为catalina
catalina_home就是tomcat安装路径:D:\Program Files\apache-tomcat-8.0.36\bin
修改端口

目录

默认站点

创建一个静态项目:
在webapps创建文件夹hello\index.html 在index.html里写点东西 重启tomcat 访问:http://127.0.0.1:8080/hello/index.html
创建动态网站
在web-int

hello2下创建


web.xml
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1" metadata-complete="true"> </web-app>
测试访问:
index.jsp
<%@page pageEncoding="utf-8"%>
<html>
<title>tomcat dynamic page TEST</title>
<body>
<h1>tomcat dynamic page TEST</h1>
<p>tomcat dynamic page TEST</p>
<hr>
<h3>
${header['User-Agent']}
</h3>
</body>
</html>
http://localhost:8080/hello2/index.jsp

注意事项:
在webapps创建文件夹WEB-INF/web.xml(从root里拷贝,然后修改)--->如上
创建静态或动态页面 (可以直接将 WEB-INF/hello2拷过去),创建index.jsp--->如上
访问:
http://127.0.0.1:8080/hello2/index.jsp 如上 ,即动态网站成功咯
动态网站所需
webapps/ hello2/index.jsp hello2/WEB-INF/web.xml
404错误:
http://127.0.0.1:8080/hello2/index.html
http://127.0.0.1:8080/hello2/WEB-INF/index.jsp
WEB-INF这个目录下所有东西都似乎受保护的,浏览器均无法访问.
这样可以访问:
http://127.0.0.1:8080/hello2/xxx/index.html

myeclipse新建web项目

让myeclipse管理tomcat
添加自己安装的tomcat到myeclipse





启动tomcat

同步项目到/D:\Program Files\apache-tomcat-8.0.36\webapps 下.
即自动将代码放到那个目录下.
测试访问:

一个项目结构
<<hello4.zip>>

配置外部应用
方法1:
修改server.xml 在host标签里写 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context path="hello44" docBase="F:/hello4"/> 浏览器url 网站文件目录 …… </Host>
测试访问: http://localhost:8080/hello44

方法2:
在D:\Program Files\apache-tomcat-8.0.36\conf\Catalina\localhost 下新建hello55.xml

给hello55添加内容,需要指定网站路径. -->文件名就是项目名

测试:

配置外部应用:
方法1:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context path="hello44" docBase="F:/hello4"/> #在server.xml里添加这行即可. url访问地址 网站文件地址
方法2:
conf\Catalina\localhost 创建hello55.xml --->文件名即为访问url. <Context docBase="F:/hello5"/> --->指定网站文件路径
创建虚拟主机:
希望通过www.lanny.com 访问到项目
3步骤:
1,修改端口-->默认8080改成80
2,修改hosts -->添加www.lanny.com
3,修改server.xml 如下
<Host name="www.lanny.com" appBase="F:/webapps" --->指定路径,将项目文件放在F:/webapps/ROOT下即可. unpackWARs="true" autoDeploy="true"> </Host>


server.xml配置文件

1个host标签1个虚拟主机
1个Context 1个项目

connector服务员

可以理解为一套完整的服务系统.
connector 与客户直接打交道的是 服务员.
host 后厨分部门--海鲜馆 川菜
context 厨子
http协议的理解
见图片
请求头

响应头


状态码302

referer的2大功能:
1,统计从百度过来的次数
2,防盗链

浙公网安备 33010602011771号