JDK+Tomcat 服务器配置+腾讯云Win2012 R2 配置安装
博客 https://blog.csdn.net/boom_man 是我个人的。## 一、JDK下载安装:
### 1.JDK的下载
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
---
![注意要勾选同意协议 ,JDK下载](http://img.blog.csdn.net/20170320191221832?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
---
### 2.JDK的安装
JDK安装目录:C:\Java\JDK
JRE安装目录:C:\Java\JRE
---
### 3.JDK的环境变量配置
JAVA_HOME=C:\Java\JDK
![填写安装目录](http://img.blog.csdn.net/20170320192009539?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![这里写图片描述](http://img.blog.csdn.net/20170320192039930?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;(注意前面有个”.“,这个点代表当前目录)
![这里写图片描述](http://img.blog.csdn.net/20170320192144643?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
Path=
%JAVA_HOME%\bin;(在原有的基础上添加%JAVA_HOME%\bin)
!(http://img.blog.csdn.net/20170320192039930?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
###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)
![根据自己服务器挑选](http://img.blog.csdn.net/20170320190913127?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
###2.Tomcat安装
解压到C:盘,改名,最终改名tomcat
![目录如下](http://img.blog.csdn.net/20170320192349255?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
/*
注意我没设置,如果不成功可以尝试
修改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
目的是为了启动一次服务
![安装服务](http://img.blog.csdn.net/20170320192918137?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
service.bat install
![这里写图片描述](http://img.blog.csdn.net/20170320193134060?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
服务自启动设置
![这里写图片描述](http://img.blog.csdn.net/20170320193236830?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9vbV9tYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
---
###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"/>
``` 小白 这是干啥用的? sdbxzl 发表于 2019-2-18 13:14
小白 这是干啥用的?
服务器配置Java环境变量 {:1_893:}谢谢分享 挺实用 不错,支持一下 不错,收藏一下。 做了那么多年,环境变量已经忘记怎么配置的了,看着挺实用:victory: 希望楼主更新能一期linux环境下的环境配置,服务器还是用linux的多点! Tomcat服务器做什么用的?
页:
[1]