Referring to this blog: install Tomcat 8 and set up from the start on Ubuntu 18.04 was successful.
However, a problem encountered during: When running the command sudo systemctl start tomcat, the error:
Warning: The unit file, source configuration file or drop-ins of tomcat.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for tomcat.service failed because the control process exited with error code.
See "systemctl status tomcat.service" and "journalctl -xe" for details.
Use the command: systemctl status tomcat, view the status:
Warning: The unit file, source configuration file or drop-ins of tomcat.service changed on disk. Run 'systemctl daemon-reload' to reload units.
● tomcat.service - Tomcat 8 servlet container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-02-15 00:45:14 CST; 8s ago
Process: 2834 ExecStart=/usr/local/apache-tomcat-8.5.50/bin/startup.sh (code=exited, status=217/USER)
2月 15 00:45:14 humen-virtual-machine systemd[1]: Starting Tomcat 8 servlet container...
2月 15 00:45:14 humen-virtual-machine systemd[2834]: tomcat.service: Failed to determine user credentials: No such process
2月 15 00:45:14 humen-virtual-machine systemd[2834]: tomcat.service: Failed at step USER spawning /usr/local/apache-tomcat-8.5.50/bin/startup.sh: No such process
2月 15 00:45:14 humen-virtual-machine systemd[1]: tomcat.service: Control process exited, code=exited status=217
2月 15 00:45:14 humen-virtual-machine systemd[1]: tomcat.service: Failed with result 'exit-code'.
2月 15 00:45:14 humen-virtual-machine systemd[1]: Failed to start Tomcat 8 servlet container.
According to No SUCH Process , I guess is not enough tomcat.service file permissions, see, it really is a read-only:
-rw-r--r-- 1 root root 694 2月 15 00:45 tomcat.service
Restart the tomcat service, after the success of elevated privileges, and finally set the boot from the start.
sudo chmod 777 tomcat.service
humen@humen-virtual-machine:/etc/systemd/system$ sudo systemctl daemon-reload
humen@humen-virtual-machine:/etc/systemd/system$ sudo systemctl start tomcat
humen@humen-virtual-machine:/etc/systemd/system$ systemctl status tomcat
● tomcat.service - Tomcat 8 servlet container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2020-02-15 00:50:24 CST; 13s ago
Process: 2885 ExecStart=/usr/local/apache-tomcat-8.5.50/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 2892 (java)
Tasks: 20 (limit: 4609)
CGroup: /system.slice/tomcat.service
└─2892 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.util.logging.config.file=/usr/local/apache-tomcat-8.5.50/conf/logging.properties -Djava.util.logging.manager=org.apach
2月 15 00:50:24 humen-virtual-machine systemd[1]: Starting Tomcat 8 servlet container...
2月 15 00:50:24 humen-virtual-machine startup.sh[2885]: Tomcat started.
2月 15 00:50:24 humen-virtual-machine systemd[1]: Started Tomcat 8 servlet container.
lines 1-12/12 (END)
humen@humen-virtual-machine:/etc/systemd/system$ sudo systemctl enable tomcat
Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.
After the restart success! ! !