安装jdk1.8

apt-get install openjdk-8-jdk

安装tomcat 8



 useradd -m -U -d /opt/tomcat -s /bin/false tomcat
//添加运行用户
cd /tmp
wget http://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.51/bin/apache-tomcat-8.5.51.zip
unzip apache-tomcat-*.zip
mv apache-tomcat-*/ /opt/tomcat
chown -R tomcat: /opt/tomcat
chmod +x /opt/tomcat/latest/bin/*.sh

开机启动tomcat 8

添加新的/etc/rc.local 文件



cat <<EOF >/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/bin/su -s /bin/bash -c "/opt/tomcat/bin/startup.sh" tomcat
exit 0
EOF

//把启动tomcat脚本丢在exit 0之前即可

也可以写成独立启动脚本



#!/bin/bash
/bin/su -s /bin/bash -c "/opt/tomcat/bin/startup.sh" tomcat

chmod +x /etc/rc.local

systemctl start rc-local

标签: debian, 安装, tomcat, openjdk, 开机

添加新评论