打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
CentOS7 安装tomcat7.x为系统服务器 Systemctl管理Tomcat
本文转载:http://blog.chinaunix.net/uid-24648266-id-5729891.html
CentOS7开始,从/etc/init.d脚本改为了systemctl管理服务。
亲自测试成功。
1.首先,需要为tomcat配置pid。
bin/catalina.sh
[java] view plain copy
# Copy CATALINA_BASE from CATALINA_HOME if not already set
[ -z "$CATALINA_BASE" ] && CATALINA_BASE="$CATALINA_HOME"
# 设置pid。一定要加在CATALINA_BASE定义后面,要不然pid会生成到/下面
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
tomcat.pid文件与bin目录平级。
2.创建tomcat.service文件
/lib/systemd/system/tomcat.service
[java] view plain copy
[Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment="JAVA_HOME=/home/jdk/jdk1.7.0_79"
PIDFile=/home/tomcat/apache-tomcat-7.0.47/tomcat.pid
ExecStart=/home/tomcat/apache-tomcat-7.0.47/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Environment="JAVA_HOME=/home/jdk/jdk1.7.0_79" 这里要配置环境变量,在/etc/profile中的配置在系统服务中不生效。
3.设置为开机启动
[java] view plain copy
systemctl enable tomcat.service
4.其它
修改tomcat.service文件后需要执行下面命令使其生效:
systemctl daemon-reload
查询tomcat 进程  ps -ef | grep "tomcat"| grep -v grep
如果多个tomcat,则拷贝到不同的目录,使用不同的端口。tomcat.service文件名不同即可。
例如:tomcat1.service tomcat2.service tomcat3.service
启动nginx服务
systemctl start nginx.service设置开机自启动
systemctl enable nginx.service停止开机自启动
systemctl disable nginx.service查看服务当前状态
systemctl status nginx.service重新启动服务
systemctl restart nginx.service查看所有已启动的服务
systemctl list-units --type=service
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Tomcat 8在CentOS 7的守护进程设置
CentOS7安装 Tomcat 8 完整步骤
centos 安装配置Tomcat--详细步骤
centos7 Tomcat 安装(root下安装,王飞测试过)
Linux下Java环境的JDK Tomcat Mysql安装和配置
Linux(Centos)环境下Tomcat9和Tomcat下SSL安装实践教程
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服