FPM打包工具
环境准备
主机名 |
WanIP |
LanIP |
应用 |
角色 |
web01 |
10.0.0.7 |
172.16.1.7 |
fpm |
打包工具 |
web02 |
10.0.0.8 |
172.16.1.8 |
yumrepo |
yum仓库 |
web03 |
10.0.0.9 |
172.16.1.9 |
|
rpm包的客户端 |
fpm打包工具安装
# 0.安装依赖
[root@web01 ~]# yum install -y rpm-build
# 1.下载fpm打包工具(ruby)
[root@web01 ~]# wget http://test.driverzeng.com/other/fpm-1.3.3.x86_64.tar.gz
# 2.解压
[root@web01 ~]# tar xf fpm-1.3.3.x86_64.tar.gz
# 3.安装ruby环境
[root@web01 ~]# yum install -y ruby rubygems ruby-devel
gem ruby应用商店 .gem
yum CentOS应用商店 .rpm
pip python库应用商店
# 4.查看gem源
[root@web01 ~]# gem source --list
*** CURRENT SOURCES ***
https://rubygems.org/
# 5.删除官方源
[root@web01 ~]# gem sources --remove https://rubygems.org/
# 6.更换阿里云gem源
[root@web01 ~]# gem sources -a https://mirrors.aliyun.com/rubygems/
https://mirrors.aliyun.com/rubygems/ added to sources
[root@web01 ~]# gem source --list
*** CURRENT SOURCES ***
https://mirrors.aliyun.com/rubygems/
# 7.安装fpm
[root@web01 ~]# gem install *.gem
# 8.检查是否安装成功
[root@web01 ~]# fpm --version
1.3.3
源码安装nginx
# 0.安装依赖
[root@web01 nginx-1.22.1]# yum install -y pcre-devel zlib-devel openssl-devel
# 1.下载nginx源码包
[root@web01 ~]# wget https://nginx.org/download/nginx-1.22.1.tar.gz
# 2.解压
[root@web01 ~]# tar xf nginx-1.22.1.tar.gz
# 3.生成
[root@web01 nginx-1.22.1]# ./configure --prefix=/app/nginx-1.22.1 --with-http_ssl_module
# 4.编译
[root@web01 nginx-1.22.1]# make
# 5.安装
[root@web01 nginx-1.22.1]# make install
fpm
-s dir # 指定将目录、文件打包成rpm
-t rpm # 打包成rpm包
-n nginx # name rpm包的名字
-v 1.6.3 # rpm包的版本
-d 'pcre-devel,openssl-devel' # 指定依赖
--post-install /server/scripts/nginx_rpm.sh # 安装之后,需要执行的命令(脚本)
-f /application/nginx-1.6.3/ # 指定打包的目录
# yum命令可以帮你自动解决依赖关系
## 编写脚本
[root@web01 nginx-1.22.1]# vim /root/install_nginx.sh
#!/bin/bash
groupadd www -g 666
useradd www -u 666 -g 666 -s /sbin/nologin -M
ln -s /app/nginx-1.22.1 /app/nginx
fpm -s dir -t rpm -n yl_nginx -v 1.22.1 -d 'pcre-devel,openssl-devel,zlib-devel' --post-install /root/install_nginx.sh -f /app/nginx-1.22.1
fpm -s dir -t rpm -n yl_nginx -v 1.22.1 --post-install /root/install_nginx.sh -f /app/nginx-1.22.1