一、JDK下载安装:
1.JDK的下载
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2.JDK的安装
JDK安装目录:C:\Java\JDK
JRE安装目录:C:\Java\JRE
3.JDK的环境变量配置
JAVA_HOME=C:\Java\JDK
CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;(注意前面有个”.“,这个点代表当前目录)
Path=
%JAVA_HOME%\bin;(在原有的基础上添加%JAVA_HOME%\bin)
4.环境配置检验
在cmd中输入 java -version
查看版本
java
javac
查看是否有错误
Tomcat下载与安装
1.Tomcat下载
Tomcat官网:
http://tomcat.apache.org/
Tomcat 7.0.6
http://tomcat.apache.org/download-70.cgi
Tomcat下载安装:
版本自己下载,我的是win2008 R2 下载的 Core: 64-bit Windows zip (pgp, md5, sha1)
2.Tomcat安装
解压到C:盘,改名,最终改名tomcat
/
注意我没设置,如果不成功可以尝试
修改CLASSPATH变量
CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%TALINA_HOME%\common\lib\servlet.jar
只需在该变量后增加%TALINA_HOME%\common\lib\servlet.jar 即可。
/
先打开:
C:/tomcat/startup.exe
目的是为了启动一次服务
service.bat install
服务自启动设置
3.Tomcat测试
然后地址栏输入
127.0.0.1:8080
即可进入
4.Tomcat修改默认页面
即修改c:/tomcat/conf/server.xml
修改默认页面:
访问http://localhost:8080的时候,Tomcat默认指向了ROOT项目,那该怎么做可以让Tomcat指向自定义项目呢?
<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 标签内加入如下代码段,docBase属性可指定项目名称,将其设置为"examples"
<Context path="" docBase="examples" reloadable="true" crossContext="true">
</Context>
修改后的Host 标签
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="examples" reloadable="true" crossContext="true">
</Context>
<!-- 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>
5.Tomcat修改默认端口改8080为80端口
即修改c:/tomcat/conf/server.xml
tomcat\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" />
6.关于用户名和密码登陆的问题
分别涉及到管理员可视化配置和text管理热部署
即修改c:/tomcat/conf/tomcat-users.xml
进入
http://localhost:8080/manager
http://localhost:8080/host-manager
http://localhost:8080/manager/text
用户名和密码问题
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="123456" roles="admin-gui,manager-gui,manager-script"/>