Ubuntu做Tomcat服务:insserv: warning: script 'tomcat' missing LSB tags and overrides

Ubuntu上对tomcat做服务时,遇到报错信息。

当时我的/etc/init.d/tomcat追加的配置如下:

#!/bin/sh

#chkconfig:2345 10 90
#description:Tomcat Service

CATALINA_HOME=/usr/local/apache-tomcat-7.0.82
JAVA_HOME=/usr/local/jdk1.8.0_161

在执行chkconfig命令注册服务时,报错:

root@hanchao-virtual-machine:/etc/init.d# chkconfig --add tomcatg
chkconfig:未找到命令

于是,安装chkconfig,同样失败:

root@hanchao-virtual-machine:/etc/init.d# sudo apt-get install chkconfig 
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
没有可用的软件包 chkconfig,但是它被其它的软件包引用了。
这可能意味着这个缺失的软件包可能已被废弃,
或者只能在其他发布源中找到

E: 软件包 chkconfig 没有可安装候选

后来,查阅资料知道:

chkconfig命令是用于RedHat/Fedora发行版的;
而对于像Ubuntu之类的Debian发行版应该使用update-rc.d命令。

于是,尝试通过update-rc.d命令进行服务注册,还是报错:

root@hanchao-virtual-machine:/etc/init.d# sudo update-rc.d tomcat7 defaults
insserv: warning: script 'tomcat' missing LSB tags and overrides

错误信息:tomcat脚本缺少LSB标签。

于是再次查看/etc/init.d/tomcat配置,发现确实配置的不对,将其修改如下:

#!/bin/sh

### BEGIN INIT INFO
# Provides:          tomcat
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: The tomcat Java Application Server
### END INIT INFO

CATALINA_HOME=/usr/local/apache-tomcat-7.0.82
JAVA_HOME=/usr/local/jdk1.8.0_161

然后从新注册tomcat服务

root@hanchao-virtual-machine:/etc/init.d# sudo update-rc.d tomcat defaults

并无报错,成功!


通过service命令启动tomcat服务:

root@hanchao-virtual-machine:/etc/init.d# service tomcat start 

然后,在浏览器中访问默认地址:http://127.0.0.1:8080/

如下:
这里写图片描述

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值