CentOS 7 安裝 tomcat9

Tomcat安裝與配置

安裝tomcat前需要先安裝Java運行環境,不然會閃退,tomcat依賴於Java運行環境

1、下載tomcat9

https://tomcat.apache.org/download-90.cgi

2、解壓tomcat9

tar -zxv -f apache-tomcat-9.0.54.tar.gz

3、重命名爲tomcat9

mv apache-tomcat-9.0.54 tomcat9

4、移動到/usr/local

mv tomcat9 /usr/local/

設置爲開機啓動

1、使用 systemctl 創建 tomcat 服務

在/usr/lib/systemd/system目錄添加 tomcat.service

tomcat.service

[Unit]
Description=tomcat
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

2、重載系統服務

systemctl daemon-reload

3、設置開機啓動

systemctl enable tomcat.service

4、tomcat服務使用

# 啓動服務
systemctl start tomcat.service

# 停止服務
systemctl stop tomcat.service

# 重啓服務
systemctl reload tomcat.service

# 檢查服務狀態
systemctl status tomcat.service

5、訪問測試

curl localhost:8080
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章