基本環境準備
jdk安裝配置。安裝目錄例如:/usr/JAVA/jdk1.8.0_05
Tomcat下載放到約定目錄。例如:/usr/local/dmstomcat
tomcat做成系統服務
把tomcat做成系統服務,就可以使用service systemctl 快速管理tomcat服務,自啟動等。
操作步驟
/usr/lib/systemd/system/目錄下新建文件dmstomcat.service
vi /usr/lib/systemd/system/dmstomcat.service
粘貼下面內容:
[Unit] Description=dmstomcat After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking Environment='JAVA_HOME=/usr/java/jdk1.8.0_05' Environment='CATALINA_PID=/usr/local/dms/bin/tomcat.pid' Environment='CATALINA_HOME=/usr/local/dms' Environment='CATALINA_BASE=/usr/local/dms' Environment='CATALINA_OPTS=-Xms2048M -Xmx2048M -server -XX:+UseParallelGC' WorkingDirectory=/usr/local/dms/ ExecStart=/usr/local/dms/bin/startup.sh ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
設置為開啟機啟動:systemctl enable dmstomcat
常用服務命令:
啟動服務:systemctl start dmstomcat 停止服務:systemctl stop dmstomcat 重啟服務:systemctl restart dmstomcat 檢查狀態:systemctl status dmstomcat