在 CentOS 7 里安装 OpenJDK 1.8 和 Tomcat 9.0

感谢“姑娘们”。

环境:CentOS7 64位,OpenJDK 1.8 和 Tomcat 9.0

过程:

1.yum update # 更新软件
2.yum install java-1.8.0-openjdk-devel # 安装 OpenJDK 1.8
tomcat9-2.png
3.wget http://ftp.cuhk.edu.hk/pub/packages/apache.org/tomcat/tomcat-9/v9.0.29/bin/apache-tomcat-9.0.29.tar.gz # 从镜像站点中下载 tomcat 9.0 安装包
4.mv apache-tomcat-9.0.29 /opt/tomcat # 解压后,移到/opt目录
5.useradd -M -d /opt/tomcat tomcat # 添加tomcat用户,设置默认目录路径
6.chown -R tomcat. /opt/tomcat # 让tomcat用户有相应目录的拥有者权限
7.vi /etc/systemd/system/tomcat.service # 创建tomcat启动文件,内容如下:

[Unit]
Description=Apache Tomcat 9 Servlet Container
After=syslog.target network.target

[Service]
User=tomcat
Group=tomcat
Type=forking
Environment=CATALINA_PID=/opt/tomcat/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

tomcat9-3.png
8.systemctl daemon-reload # 重载服务
9.systemctl start tomcat # 启动tomcat服务
10.systemctl enable tomcat # 让tomcat服务随开机自动运行
11.在浏览器里访问,可以看到大脸猫
tomcat9-4.png

参考:https://www.rosehosting.com/blog/install-tomcat-9-on-centos-7/

标签: tomcat9

添加新评论