龙空技术网

[centos7]fpm工具一键安装脚本(fpm是制作rpm包的工具)

小白一起学IT 248

前言:

目前小伙伴们对“centos7定制”大概比较着重,你们都需要知道一些“centos7定制”的相关知识。那么小编在网摘上网罗了一些对于“centos7定制””的相关内容,希望咱们能喜欢,朋友们快快来了解一下吧!

#!/bin/bash# fpm软件常用参数# 参数 参数说明# -s 指定源类型# -t 指定目标类型,即想要制作为什么包# -n 指定包的名字# -v 指定包的版本号# -C 指定打包的相对路径# -d 指定依赖于哪些包# -f 第二次打包时目录下如果有同名安装包存在,则覆盖它# -p 输出的安装包的目录,不想放在当前目录下就需要指定# --post-install 软件包安装完成之后所要运行的脚本;同--after-install# --pre-install 软件包安装完成之前所要运行的脚本;同--before-install# --post-uninstall 软件包卸载完成之后所要运行的脚本;同--after-remove# --pre-uninstall 软件包卸载完成之前所要运行的脚本;同--before-remove# 示范: # 打包php# fpm -s dir -t rpm -n php -v 5.5.32 -d 'zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel libmcrypt-devel mhash mcrypt' --post-install /server/scripts/php_install_devel.sh -f /application/php-5.5.32/ # 打包mysql# fpm -s dir -t rpm -n mysql -v 5.6.38 -d 'ncurses-devel libaio-devel cmake' --post-install /server/scripts/mysql_install_devel.sh -f /application/mysql-5.6.38/ # yum -y localinstall mysql-5.6.38-1.x86_64.rpmos_mysql_system () {os=$(grep -iEo "CentOS release 6.[56789]" /etc/redhat-release| awk -F "[ ]+" '{print $NF}'|grep [0-9] ||grep\ -iEo "CentOS Linux release 7.[12345]" /etc/redhat-release |awk -F "[ ]+" '{print $NF}')}centos6_fpm () { [ `fpm -v` ]&& exit 0 yum groupinstall "Development Tools" -y yum install openssl-devel -y wget  tar xvfvz ruby-2.4.4.tar.gz cd ruby-2.4.4 ./configure make&&make install a_02=`gem sources list|egrep "http|https" 2>/dev/null` gem source -a  -r $a_02 gem install fpm && echo "fpm版本号为 `fpm -v`"}centos7_fpm (){ [ `fpm -v` ]&& exit 0 a_01=`rpm -qa ruby rubygems gcc ruby-devel|wc -l` [ $a_01 -ne 4 ]&&{  yum -y install ruby rubygems ruby-devel gcc a_02=`gem sources list|egrep "http|https" 2>/dev/null` gem source -a  -r $a_02 gem install json && gem install fpm && echo "fpm版本号为 `fpm -v`" }||{ a_02=`gem sources list|egrep "http|https" 2>/dev/null` gem source -a  -r $a_02  gem install json && gem install fpm && echo "fpm版本号为 `fpm -v`" }}install_fpm (){ [[ $os>=6.5 ]]&&[[ 6.9>=$os ]]&& centos6_fpm #centos6 [[ $os>=7.0 ]]&&[[ 7.5>=$os ]]&& centos7_fpm #centos7}os_mysql_systeminstall_fpmyum install -y rpm-build
网络异常的时候需要多试几次,参考实例

1.4.2 FPM工具常用参数

1.5 【实例】定制nginx的RPM包

1.5.1 安装nginx(一键化脚本)

yum install -y rpm-build

[root@20 ~]# cat /root/init_a.sh#!/bin/bashcat >>/etc/sysctl.conf<<EOFnet.ipv4.tcp_fin_timeout=2net.ipv4.tcp_tw_reuse=1net.ipv4.tcp_tw_recycle=1net.ipv4.tcp_syncookies=1net.ipv4.tcp_keepalive_time=600net.ipv4.ip_local_port_range = 4000 65000net.ipv4.tcp_max_syn_backlog= 16384net.ipv4.tcp_max_tw_buckets=36000net.ipv4.route.gc_timeout=100net.ipv4.tcp_syn_retries=1net.ipv4.tcp_synack_retries=1net.core.somaxconn=16384net.core.netdev_max_backlog=16384net.ipv4.tcp_max_orphans=16384EOFsysctl -p[root@20 ~]#yum install -y rpm-buildmkdir	 -p /usr/local/init_afpm -s dir -t rpm -n init_a -v 1.0 -d 'vim-minimal' --post-install /root/init_a.sh -f /usr/local/init_a/ yum install init_a-1.0-1.x86_64.rpm -y

标签: #centos7定制