第一步,创建tomcat目录并进入
[root@localhost ~]# mkdir -p /usr/local/tomcat
[root@localhost ~]# cd /usr/local/tomcat
第二步,tomcat目录下载并解压Tomcat9
[root@localhost tomcat]# wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.16/bin/apache-tomcat-9.0.16.tar.gz
[root@localhost tomcat]# tar -zxvf apache-tomcat-9.0.16.tar.gz
第三步,配置/etc/profile,并立即生效
[root@localhost tomcat]# vim /etc/profile
CATALINA_HOME=/usr/local/tomcat/apache-tomcat-9.0.16
CATALINA_BASE=/usr/local/tomcat/apache-tomcat-9.0.16
PATH=$PATH:$CATALINA_BASE/bin
export PATH CATALINA_BASE
[root@localhost tomcat]# source /etc/profile
第四步,修改tomcat字符编码
[root@localhost tomcat]# vim /usr/local/tomcat/apache-tomcat-9.0.16/conf/server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
第五步,配置/usr/local/tomcat/apache-tomcat-9.0.16/bin/catalina.sh
[root@localhost tomcat]# vim /usr/local/tomcat/apache-tomcat-9.0.16/bin/catalina.sh
JAVA_HOME=/usr/local/java/jdk1.8.0_201
JAVA_HOME=$JAVA_HOME/jre
# OS specific support. $var _must_ be set to either true or false.
第六步,新建tomcat服务
[root@localhost ~]# vim /lib/systemd/system/tomcat.service
[Unit]
Description=tomcat
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/tomcat/apache-tomcat-9.0.16/bin/startup.sh
ExecStop=/usr/local/tomcat/apache-tomcat-9.0.16/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
第七步,启动tomcat,并设置开机启动
[root@localhost ~]# systemctl start tomcat.service
[root@localhost ~]# systemctl enable tomcat.service
第八步,Windows 10登录
浏览器:172.16.6.15:8080
来源:oschina
链接:https://my.oschina.net/u/4386987/blog/3650452