大网数据广告活动
服务器运维问答

systemctl complains about no installation config, but it exists

· 52CE 我爱测

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 (Wan…

问题原文

原帖链接 · corsiKa · CC BY-SA 4.0

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.

社区高分解答

原帖链接 · jcomeau_ictx · CC BY-SA 4.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-10-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。