一、下载地址:Apache官网下载并安装 二、配置环境变量如下图(我的电脑/属性/高级/环境变量/新建/JAVA_HOME)
安装配置完进行测试是否成功 1 启动Tomcat 3 打开Apache官网则正确,否则错误。 4 关闭Tomcat(ctrl+C) 三、基本认识 1.安装文件夹的作用 编号 | | | | | 所有可执行命令,启动和关闭服务器的命令就在此文件夹中 | | | | | | | | | | | | Web应用程序存放的目录,web项目保存到此目录中可发布 | | | |
2.修改端口号 在conf/server.xml文件中 <Connector port="8080"protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/> <Connector port="80"protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/> 重启服务器才生效 3.配置虚拟目录 3.1 新建文件夹,并建立WEB-INF子文件夹,把webapps\ROOT\WEB-INF中web.xml拷入web-inf中。如E:\000\JavaWeb\WEB-INF下有web.xml文件一样。 3.2 然后再修改conf/server.xml文件,在最后添加语句 <Context path="/newudbful"docBase="E:\000\JavaWeb" reloadable="true"/> 如: 注意:在配置多个虚拟目录时,Path不能重名;在server.xml中一定不能有中文注释,否则无法启动Tomcat。 3.3 重启服务器,输入http://localhost/newudbful 会出如下界面 3.4 若出现HTTP Status 404错误则需再改conf/web.xml。把下面行的false改成如下的true。 <init-param> <param-name>listings</param-name> <param-value>true</param-value> </init-param> 附:HTTP状态码说明 编号 | | | | | | | | | | | | | | | | | | | | 服务器内部错误----因为意外情况,服务器不能完成请求 |
4. 配置首页 4.1 编写首页 <!doctype html> <html> <head> <metacharset="UTF-8"> <title>udbful</title> </head> <body> <center> <H1>欢迎光临!!!</H1> <H2>您好!!!</H2> </center> </body> </html> 4.2 配置 方法一:在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> 方法二:在虚拟目录文件web-inf/web.xml中添加新的目录 <welcome-file-list> <welcome-file>main.htm</welcome-file> </welcome-file-list>
以上内容参考javaweb开发实战经典(名师讲坛)。
|