Mac OS上安装Tomcat服务器的简单步骤

来源:互联网 发布:常见电信网络诈骗试题 编辑:程序博客网 时间:2024/04/30 15:46

一. 下载tomcat

  首先要到tomcat官网去下载安装包,官网下载地址如下:http://tomcat.apache.org/download-70.cgi , 注意请下载飞windows版本。和windows操作系统不一样,这个里面没有令人厌烦的注册表。

  将压缩包解压到任意一个目录,我这里是存放到/Library/tomcat 目录下面

 

二. 修改授权

  1.tomcat中的几个运行服务程序都是以*.sh结尾的,在运行之前需要授权。打开终端输入如下命令:

      sudo chmod 755 /ProgramFile/tomcat/bin/*.sh

      回车出现要输入密码:请输入本机账户密码

三. 启动tomcat服务

     1.先使用 cd 命令进入tomcat的bin目录,命令如下:

      cd /Library/Tomcat/bin 

      2.启动服务命令:

      sudo sh startup.sh

     3.启动成功,会出现如下结果:

     sing CATALINA_BASE:   /Library/Tomcat

     Using CATALINA_HOME:   /Library/Tomcat

     Using CATALINA_TMPDIR: /Library/Tomcat/temp

     Using JRE_HOME:        /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

     Using CLASSPATH:       /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar

     Tomcat started.

     如果出现如上结果,说明tomcat启动成功

四. tomcat 相关配置的修改

  打开tomcat中的 /tomcat/conf/tomcat-users.xml 文件。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<tomcat-users>
<!--
 NOTE: By default, no user is included in the "manager-gui" role required
 to operate the "/manager/html" web application. If you wish to use this app,
 you must define such a user - the username and password are arbitrary.
-->
<!--
 NOTE: The sample user and role entries below are wrapped in a comment
 and thus are ignored when reading this file. Do not forget to remove
 <!.. ..> that surrounds them.
-->
<!--
 <role rolename="tomcat"/>
 <role rolename="role1"/>
 <user username="tomcat" password="tomcat" roles="tomcat"/>
 <user username="both" password="tomcat" roles="tomcat,role1"/>
 <user username="role1" password="tomcat" roles="role1"/>
-->
<rolerolename="manager"/>
<userusername="tomcat"password="root"roles="manager"/>
</tomcat-users>

  默认<role> 都是被注释的,这里添加如下:

?
1
2
<rolerolename="manager"/>
<userusername="tomcat"password="root"roles="manager"/>

  更多配置修改,可以查看tomcat的相关资料

  这个时候输入 http://localhost:8080/ 应该就可以访问了,做java web开发的应该很熟悉,这里不再讨论


0 0
原创粉丝点击