admin avatar

debian 9安装openjdk,tomcat以及开机启动tomcat的方法

🕑 by admin





安装jdk1.8

apt-get install openjdk-8-jdk

安装tomcat 8

1
2
3
4
5
6
7
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 文件

Bash:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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之前即可

也可以写成独立启动脚本

Bash:
1
2
#!/bin/bash
/bin/su -s /bin/bash -c "/opt/tomcat/bin/startup.sh" tomcat

chmod +x /etc/rc.local

systemctl start rc-local





💘 相关文章

写一条评论

Based on Golang + fastHTTP + sdb | go1.18.3 Processed in 2ms