引言:
Tomcat是常见的免费的web服务器,前端服务很多都是通过tomcat部署的!所以多了解点肯定没坏处!
一、配置端口
1.防火墙策略中配置8888端口,并允许策略:
二、安装tomcat包
1.新建tomcat文件夹
进入 /usr/local,并新建文件夹
mkdir 文件夹名字
2.将apache-tomcat-8.5.82.tar.gz上传到新建文件夹下
你可以拖拽也可以通过 cp apache-tomcat-8.5.82.tar.gz 指定文件夹
3.解压tar.gz包
4.cd 进入tomcat的conf文件夹下的server.xml
5.将默认的8080端口服务改为8888端口:
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8888" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
如果是配置https服务:在8443 里面 需要换端口的话换,不换的话默认,里面引入ssl证书 !
三、启动tomcat服务
因为前面我们介绍过JDK环境的配置,我们就不需要再去管java版本和jdk已经环境变量是都配置成功了,不清楚的可以查看这篇文章:linux服务器中JDK的安装和配置_尔嵘的博客-CSDN博客。
1.进入bin
cd bin
2.关闭tomcat 服务
./shutdown.sh
3.启动tomcat服务
./startup.sh
也有用以下命令启动:
catalina run
四、启动效果:
默认你的tomcat启动之后,浏览器就可以访问你指定的端口了,效果如下:
五、其他相关(防火墙相关,端口)
1.启动防火墙
systemctl start firewalld
2.查看防火墙状态
systemctl status firewalld
3.开放80和8888端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=8888/tcp --permanent