web服务之tomcat部署安装
Tomcat服务
1、Tomcat介绍
Tomcat是全世界最著名的基于Java语言的轻量级应用服务器,是一款完全开源免费的Servlet容器实现。同时,它支持HTML、JS等静态资源的处理,因此又可以作为轻量级Web服务器使用
2、安装部署
2.1安装java环境
yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel -y
2.2二进制安装java并配置环境
# tar -xvf jdk-8u211-linux-x64.tar.gz -C /usr/local
# cd /usr/local/
# mv jdk1.8.0_211/ jdk1.8.0
# vim /etc/profile.d/jdk1.8.sh #设置环境变量
# java environment
export JAVA_HOME=/usr/local/jdk1.8.0
export PATH=$JAVA_HOME/bin/:$PATH
# source /etc/profile.d/jdk1.8.sh
验证
[root@controller1 ~]# java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
2.1yum源安装
# yum install tomcat-admin-webapps tomcat-webapps -y
# systemctl start tomcat
# systemctl enable tomctl
# ss -tnl 查看8009、8080端口开启
二进制安装
# wget https://www-eu.apache.org/dist/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz
# tar -xvf apache-tomcat-8.5.45.tar.gz -C /usr/local/
# cd /usr/local/
# ln -sv apache-tomcat-8.5.45/ tomcat
# ll
tomcat -> apache-tomcat-8.5.45/
# cd tomcat/bin/
# ./catalina.sh——help
# ./catalina.sh version
# ./catalina.sh start
# ./catalina.sh stop
# ss -tanlp查询端口
设置启动服务软链接并启动服务
# ln -s /usr/local/tomcat/bin/catalina.sh /usr/lib/systemd/system/tomcat
# systemctl start tomcat
建立系统用户
# useradd -r tomcat
# chown -R tomcat.tomcat /usr/local/tomcat
# su - tomcat -c '/usr/local/tomcat/bin/catalina.sh start' 指定tomcat运行进程
# su - tomcat -c '/usr/local/tomcat/bin/catalina.sh stop ' 指定tomct停止进程
# ps -ef | grep tomcat
# ss -tanlp