Tomcat8.X 开机自启动服务

##1.在$CATALINA_BASE目录下,创建tomcat.pid

# cd $CATALINA_BASE
# touch tomcat.pid

##2. $CATALINA_BASE/bin目录下创建setenv.sh

# cd $CATALINA_BASE/bin
# vim setenv.sh
#set java runtime environment variable
export JAVA_HOME=/opt/jdk1.8.0_111
export JRE_HOME=/opt/jdk1.8.0_111/jre
export CATALINA_HOME=/opt/tomcat8/manager
export CATALINA_BASE=/opt/tomcat8/manager
#add tomcat pid
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
#add Java opts
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"

#**注意:export配置的路径根据自己实际环境修改**

3.在/usr/lib/systemd/system目录下增加tomcat.service,目录必须是绝对目录

[Unit]

Description=Tomcat Manager

After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]

Type=forking

PIDFile=/opt/tomcat8/manager/tomcat.pid

ExecStart=/opt/tomcat8/manager/bin/startup.sh

ExecReload=/bin/kill -s HUP $MAINPID

ExecStop=/bin/kill -s QUIT $MAINPID

PrivateTmp=true

[Install]

WantedBy=multi-user.target

4.配置开机启动

  • 配置成服务
    systemctl enable tomcat.service

  • 启动Tomcat
    systemctl start tomcat.service

  • 停止Tomcat
    systemctl stop tomcat.service

  • 重启Tomcat
    systemctl restart tomcat.service

  • 删除Tomcat服务
    systemctl disable tomcat.service


5.参考

    <Connector executor="tomcatThreadPool"
               port="8080" 
               protocol="org.apache.coyote.http11.Http11Nio2Protocol" 
               connectionTimeout="20000" 
               maxConnections="10000" 
               redirectPort="8443" 
               enableLookups="false" 
               acceptCount="100" 
               maxPostSize="10485760" 
               compression="on" 
               disableUploadTimeout="true" 
               compressionMinSize="2048" 
               acceptorThreadCount="2" 
               URIEncoding="utf-8"/>
      <Host name="localhost"  appBase="/usr/dianzan/manager"
            unpackWARs="true" autoDeploy="true">

        <Context path="" docBase="/usr/dianzan/manager/ROOT" reloadable="true" />

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值