我尝试在 centos-release-7-4.1708.el7.centos.x86_64 中运行 tomcat 7
这些是遵循的步骤:
yum install java-1.7.0-openjdk-devel java-1.7.0-openjdk
测试是否安装:
echo $JAVA_HOME
/usr/java/jdk/
echo $JRE_HOME
/usr/java/jdk/jre
安装tomcat 7
yum install tomcat tomcat-webapps tomcat-admin-webapps
systemctl stop tomcat
systemctl start tomcat
systemctl enable tomcat
它应该创建一个指向 tomcat.service 的符号链接(symbolic link),但是没有...
systemctl status tomcat
tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/usr/lib/systemd/system/tomcat.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2017-11-13 10:26:33 WET; 4min 7s ago
Process: 2825 ExecStart=/usr/libexec/tomcat/server start (code=exited, status=127)
Main PID: 2825 (code=exited, status=127)
systemd[1]: Started Apache Tomcat Web Application Container.
systemd[1]: Starting Apache Tomcat Web Application Container...
server[2825]: /usr/libexec/tomcat/server: Failed to set JAVACMD
systemd[1]: tomcat.service: main process exited, code=exited, status=127/n/a
systemd[1]: Unit tomcat.service entered failed state.
systemd[1]: tomcat.service failed.
更新 1
/usr/lib/systemd/system 中文件 tomcat.service 的内容
# Systemd unit file for default tomcat
#
# To create clones of this service:
# DO NOTHING, use tomcat@.service instead.
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=simple
EnvironmentFile=/etc/tomcat/tomcat.conf
Environment="NAME="
EnvironmentFile=-/etc/sysconfig/tomcat
ExecStart=/usr/libexec/tomcat/server start
SuccessExitStatus=143
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target
最佳答案
将/etc/tomcat/tomcat.conf中的JAVA_HOME替换为/usr/java/jdk/
关于java - 在centos 7中启动tomcat 7的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47262237/