##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 "%r" %s %b" />
</Host>