Linux-安装Tomcat

Tomcat-学习目录

1、下载软件

1.1、前提

需要安装JDK,具体请看文章:https://www.cnblogs.com/ygbh/p/17368832.html

1.2、下载tomcat

官网下载地址:https://tomcat.apache.org/download-90.cgi

curl -k -o apache-tomcat-9.0.74.tar.gz https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.74/bin/apache-tomcat-9.0.74.tar.gz

2、安装tomcat

2.1、解压安装

tar xf apache-tomcat-9.0.74.tar.gz -C /usr/local/
ln -s /usr/local/apache-tomcat-9.0.74 /usr/local/tomcat

2.2、启动tomcat服务

]# /usr/local/tomcat/bin/startup.sh 
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/jdk
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Tomcat started.


]# netstat -tunlp | grep java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 2436/java tcp6 0 0 :::8080 :::* LISTEN 2436/java

2.3、浏览器访问测试

3、设置开机自启动

3.1、编写service

cat >/usr/lib/systemd/system/tomcat.service<<'EOF'
[Unit]
Description=Apache Tomcat web Application Container
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment=CATALINA_HOME=/usr/local/tomcat
Environment=CATALINA_BASE=/usr/local/tomcat
Environment=JAVA_HOME=/usr/local/jdk
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/local/tomcat/bin/shutdown.sh
[Install]
wantedBy=multi-user.target
EOF

3.2、启动服务

systemctl daemon-reload
systemctl enable tomcat
systemctl stop tomcat
systemctl start tomcat

3.3、检查端口是否正常

]# systemctl start tomcat
]# netstat -tunlp | grep java
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      2699/java           
tcp6       0      0 :::8080                 :::*                    LISTEN      2699/java     
]# systemctl stop tomcat ]# netstat -tunlp | grep java

 

posted @ 2023-05-03 14:25  小粉优化大师  阅读(79)  评论(0编辑  收藏  举报