1. Download tomcat and save it to /opt/tomcat
2. change permission of all files in /opt/tomcat/bin directory to +x
chmod +x /opt/tomcat/bin/
3. sudo vim /etc/systemd/system/tomcat.service
[Unit]
Description=Tomcat Web Application Container
After=network.target multi-user.target
[Service]
Type=forking
User=username #replace with your username
Group=username #replace with your groupname
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_TMPDIR=/opt/tomcat/temp"
Environment="JRE_HOME=/home/newmkg/.sdkman/candidates/java/current"
Environment="JAVA_HOME=/home/newmkg/.sdkman/candidates/java/current"
Environment="CLASSPATH=/opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
-------------------
4. run commands to start tomcat
sudo systemctl daemon-reload;
sudo systemctl enable tomcat.service;
sudo systemctl start tomcat.service;
5. check status of tomcat
sudo systemctl status tomcat.service;
6. in case of issue try to restart tomcat via systemctl commant
sudo systemctl restart tomcat.service;
7. Is issue not resolved, run commands
sudo systemctl stop tomcat.service;
sudo systemctl disable tomcat.service;
sudo systemctl daemon-reload.service;
8. Then delete /opt/tomcat & repeat steps 1-6 above
Comments
Post a Comment
If you have any doubts, please let me know.