Tomcat安装及配置(Linux系统)

环境说明:Linux环境,CentOS 7版本。

第一步:下载tomcat 版本,下载地址:https://tomcat.apache.org/index.html

 

我用的是zip结尾的包

解压命令:
unzip XX.zip #zip后缀结尾 结果如下:
[root@localhost apache-tomcat]# ls
apache-tomcat-9.0.20 apache-tomcat-9.0.20.zip

第二步:修改配置文件

修改访问端口号:

 第三步:启动tomcat。

通过查看文件【RUNNING.txt】,可以看到,Linux系统和Window系统启动tomcat是不同的,如下:

(4) Start Up Tomcat

(4.1) Tomcat can be started by executing one of the following commands:
On Windows:
%CATALINA_HOME%\bin\startup.bat or %CATALINA_HOME%\bin\catalina.bat start
On
*nix: $CATALINA_HOME/bin/startup.sh or $CATALINA_HOME/bin/catalina.sh start (4.2) After startup, the default web applications included with Tomcat will be available by visiting: http://localhost:8080/ (4.3) Further information about configuring and running Tomcat can be found in the documentation included here, as well as on the Tomcat web site: https://tomcat.apache.org/ (5) Shut Down Tomcat (5.1) Tomcat can be shut down by executing one of the following commands: On Windows: %CATALINA_HOME%\bin\shutdown.bat or %CATALINA_HOME%\bin\catalina.bat stop On *nix: $CATALINA_HOME/bin/shutdown.sh or $CATALINA_HOME/bin/catalina.sh stop

第四步:访问tomcat

默认本地访问地址是:  http://localhost:8080/    ,其他机器访问时,将localhost 替换成 对应的IP号就可以了(默认端口是8080,如果换过端口号,也需要更换下!)

 

其他:有时候其他电脑访问,界面显示空白,可能是防火墙限制了,添加防火墙端口如下:

[root@localhost conf]# cd /etc/sysconfig
[root@localhost sysconfig]# firewall-cmd --zone=public --add-port=8080/tcp --permanent     #添加8080端口,此为tomcat默认端口
success

命令含义:
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
firewall-cmd --reload #重启firewall

 

posted @ 2019-06-03 18:07  省略  阅读(1119)  评论(0编辑  收藏  举报