码迷,mamicode.com
首页 > 其他好文 > 详细

rpm打包tomcat

时间:2018-05-13 00:35:31      阅读:677      评论:0      收藏:0      [点我收藏+]

标签:工作   set   usr   var   build   pad   下载   spec   direct   

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 "$@" start >> "$CATALINA_OUT" 2>&1 "&"

修改为

org.apache.catalina.startup.Bootstrap “$@” 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

标签:工作   set   usr   var   build   pad   下载   spec   direct   

原文地址:https://www.cnblogs.com/LC161616/p/9030643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!