Skip to content

Instantly share code, notes, and snippets.

@russellhoff
Forked from zengxs/tomcat.service
Last active November 28, 2017 21:13
Show Gist options
  • Save russellhoff/d6e804fb21486ad23e4d6ce710e0842e to your computer and use it in GitHub Desktop.
Save russellhoff/d6e804fb21486ad23e4d6ce710e0842e to your computer and use it in GitHub Desktop.
tomcat systemd service script
# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/opt/apache-tomcat-8.5.23/bin/catalina.sh start
ExecStop=/opt/apache-tomcat-8.5.23/bin/catalina.sh stop
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target
@russellhoff
Copy link
Author

russellhoff commented Nov 28, 2017

Create tomcat's user (select a password):
$ sudo adduser tomcat

Edit ~/.bashrc file and append the following line at the bottom (replace the directory with yours):
export CATALINA_HOME="/opt/apache-tomcat-8.5.23"

Edit the current file
$ sudo vim /etc/systemd/system/tomcat.service

Reload systemd service daemons:
$ sudo systemctl daemon-reload

Enable service:
$ sudo systemctl enable tomcat.service Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.

Start service by typing:
$ sudo systemctl start tomcat.service

Stop service by typing:
$ sudo systemctl stop tomcat.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment