rpm打包tomcat
Posted 钢闸门的笔记收藏册
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rpm打包tomcat相关的知识,希望对你有一定的参考价值。
1.制作rpm包
yum install rpm-build -y
2.创建工作目录
mkdir -pv ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
3.准备要打包的文件
tomcat请自行下载
下载后修改配置文件,关闭ajp 8009监听
<!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> -->
修改catalina参数
CATALINA_HOME=/usr/local/tomcat JAVA_HOME=/usr/local/jdk CATALINA_PID=/usr/local/tomcat/var/tomcat.pid JAVA_OPTS="${JAVA_OPTS} -Duser.timezone=Asia/Shanghai -Dfile.encoding=utf-8 -server -XX:PermSize=512m -XX:MaxPermSize=512m -Xms4096m -Xmx4096m -Djava.awt.headless=true"
配置tomcat日志自动切割
修改catalina.sh,搜索关键词 touch "$CATALINA_OUT"
org.apache.catalina.startup.Bootstrap "[email protected]" start >> "$CATALINA_OUT" 2>&1 "&"
修改为
org.apache.catalina.startup.Bootstrap “[email protected]” start 2>&1 \ | /usr/local/sbin/cronolog “$CATALINA_BASE”/logs/catalina.%Y-%m-%d.out >> /dev/null &
下载cronlog
yum install -y cronlog
tomcat启动脚本
本次试验为centos7.3,顾准备systemd所需的单元文件
[Unit] Description=Tomcat After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/tomcat/var/tomcat.pid ExecStart=/usr/local/tomcat-8.5.29/bin/startup.sh &>/dev/null ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
编写tomcat.spec文件
%define path_name usr/local %define name_ tomcat-8.5.29 Name: tomcat Version: 8.5.29 Release: 1%{?dist} Summary: tomcat Group: tomcat License: GPL URL: http://www.test.net Packager: tomcat Vendor: tomcat Source0: tomcat-8.5.29.tar.gz Source1: tomcat.service BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot %description tomcat %prep mkdir -pv %{buildroot}/%{path_name} %setup -q %install mkdir -pv $RPM_BUILD_ROOT/%{path_name}/%{name_}/var cp -rf * $RPM_BUILD_ROOT/%{path_name}/%{name_}/ %{__install} -p -D %{SOURCE1} %{buildroot}/usr/lib/systemd/system/tomcat.service %post ln -s $RPM_BUILD_ROOT/%{path_name}/%{name_}/ $RPM_BUILD_ROOT/%{path_name}/tomcat %postun rm -fr /%{path_name}/%{name_} rm -fr /%{path_name}/tomcat %files %defattr(-,root,root,-) %attr(0755,root,root) /usr/local/ %attr(0755,root,root) /usr/lib/systemd/system/tomcat.service %attr(0755,root,root) /usr/local/tomcat-8.5.29/var %changelog * Sat Oct 24 2015 yeho 1.15-1 - Initial version
以上是关于rpm打包tomcat的主要内容,如果未能解决你的问题,请参考以下文章
web项目集成tomcat+jdk+mysql+java项目源码rpm安装包一键安装
Linux07(RPM与YUM安装JDK安装tomcat安装ideamysql5.7的安装)
在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途