我使用centos7X64最小化安装
CentOS-7-x86_64-Minimal-1708

没装jdk的同学,请移步【centos7 安装 jdk8】的文章

1.关闭firewall:

1
2
3
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
1
2
3
[root@localhost ~]# firewall-cmd --state
not running
[root@localhost ~]#

2.安装wget

1
yum -y install wget

3.下载tomcat8

1
wget http://mirrors.shuosc.org/apache/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz

4.解压

1
tar -zxvf apache-tomcat-8.5.24.tar.gz

5.移动到/usr/local

1
mv apache-tomcat-8.5.24 /usr/local/tomcat8

6.配置tomcat的jdk环境变量

1
vi /usr/local/tomcat8/conf/catalina.sh

在 OS specific support. 前面加入如下代码:

1
2
JAVA_HOME=/usr/local/java/jdk1.8.0_151
JRE_HOME=$JAVA_HOME/jre

7.配置tomcat8开机启动

在/usr/lib/systemd/system目录下增加tomcat8.service文件,内容如下:

1
vi /usr/lib/systemd/system/tomcat8.service
1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=oneshot
ExecStart=/usr/local/tomcat8/bin/startup.sh
ExecStop=/usr/local/tomcat8/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

8.允许tomcat8开机启动

systemctl enable tomcat8

9.tomcat8常见命令

1
2
3
4
5
6
7
systemctl start tomcat8.service    //启动tomcat

systemctl stop tomcat8.service //关闭tomcat

systemctl restart tomcat8.service //重启tomcat

systemctl status tomcat8.service //查看状态tomcat

最后更新: 2018年02月26日 15:51

原始链接: http://code.cookily.cn/2018/06/14/Centos7安装Tomcat8/

× 请博主喝杯可乐~
打赏二维码