6

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.

2 Answers 2

13

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

0
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).

1
  • Just use sudo systemctl status xxx to have a check!
    – Belter
    Sep 12, 2022 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.