8

While following this tutorial on installing tomcat on CentOS I came across a problem executing the line sudo systemctl enable tomcat - it complains with the following error message:

The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.

However, I clearly have an entry in my [Install] section:

[Unit]
Description=Tomcat 9 servlet container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/jre"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"

Environment="CATALINA_BASE=/opt/tomcat/latest"
Environment="CATALINA_HOME=/opt/tomcat/latest"
Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms256M -Xmx512M -server -XX:+UseParallelGC"

ExecStart=/opt/tomcat/latest/bin/startup.sh
ExecStop=/opt/tomcat/latest/bin/shutdown.sh

[INSTALL]
WantedBy=multi-user.target

How can I get it to allow me to enable this service? I believe I've done everything right that it's asking for.

corsiKa
  • 383
  • 1
  • 8
  • 19

2 Answers2

16

Your systemd unit doesn't have an [Install] section. It does, however, have an [INSTALL] section. Section names are case sensitive.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
3

A similar warning (The unit files have no [Install] section. They are not meant to be enabled using systemctl.) can also be seen on CentOS 7 (at least) when you've already enabled the service, and the symlink already exists in /etc/systemd/system/multi-user.target.wants/. I found this out when re-running make install from a Makefile intended for installing an app on a freshly provisioned droplet (VPS).

jcomeau_ictx
  • 262
  • 4
  • 13