I am trying to enable the tomcat server by default. I followed this method for installation of tomcat 9. my tomcat.service file looks like,
[Unit] Description=Apache Tomcat
After=syslog.target network.target
[Service] Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat/apache-tomcat-9.0.8/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat/apache-tomcat-9.0.8
Environment=CATALINA_BASE=/opt/tomcat/apache-tomcat-9.0.8
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
WorkingDirectory=/opt/tomcat/apache-tomcat-9.0.8
ExecStart=/opt/tomcat/apache-tomcat-9.0.8/bin/startup.sh
ExecStop=/opt/tomcat/apache-tomcat-9.0.8/bin/shutdown.sh
User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always
[Install] WantedBy=multi-user.target
I checked my tomcat server which is running on the port 8080 https://localhost:8080. But I am unable to enable the Tomcat server.
The command sudo systemctl enable tomcat returns following error.
● tomcat.service
Loaded: error (Reason: Bad message)
Active: inactive (dead)
พ.ค. 11 14:35:04 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'
พ.ค. 11 14:35:05 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'
พ.ค. 11 14:35:10 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'
พ.ค. 11 14:43:02 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'
พ.ค. 11 14:43:55 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'
พ.ค. 11 14:46:02 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'
พ.ค. 11 14:47:53 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'
พ.ค. 12 19:22:44 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'
พ.ค. 12 19:23:55 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'
พ.ค. 12 19:25:17 portal-gic systemd[1]: /etc/systemd/system/tomcat.service:1: Invalid section header '[Unit] Description=Apache Tomcat'