FPM制作rpm包-創(chuàng)新互聯(lián)

#軟件信息

成都地區(qū)優(yōu)秀IDC服務(wù)器托管提供商(創(chuàng)新互聯(lián)公司).為客戶提供專業(yè)的成都電信服務(wù)器托管,四川各地服務(wù)器托管,成都電信服務(wù)器托管、多線服務(wù)器托管.托管咨詢專線:13518219792

#FPM github :https://github.com/jordansissel/fpm

#FPM documentation :https://fpm.readthedocs.io/en/latest/

#FPM源類型與目標(biāo)類型

Things that should work Sources: gem (even autodownloaded for you) python modules (autodownload for you) pear (also downloads for you) directories tar(.gz) archives rpm deb node packages (npm) pacman (ArchLinux) packages Targets: deb rpm solaris freebsd tar directories Mac OS X .pkg files (osxpkg) pacman (ArchLinux) packages

FPM常用參數(shù):

-s   指定源類型

-t   指定目標(biāo)類型

-n   指定包的名字

-v   指定包的版本號

-C   指定打包的相對路徑

-d   指定依賴于哪些包

--url URI   給該包添加URL  (default: "http://example.com/no-uri-given")

-f     第二次包時目錄下如果有同名安裝包存在,則覆蓋它;

-p    :制作的rpm安裝包存放路徑,不想放在當(dāng)前目錄下就需要指定;

--post-install FILE  軟件包安裝完成之后所要運(yùn)行的腳本;

--pre-install FILE   軟件包安裝完成之前所要運(yùn)行的腳本;

--post-uninstall FILE  軟件包卸載完成之后所要運(yùn)行的腳本;

--pre-uninstall FILE  軟件包卸載完成之前所要運(yùn)行的腳本;

--prefix:   制作好的rpm包默認(rèn)安裝路徑;

--after-remove FILE      軟件包卸載完成后要運(yùn)行的腳本

--before-remove FILE      軟件包卸載完成前要卸載的腳本

#安裝FPM

[root@KVM_1 ~]# yum install -y ruby rubygems ruby-devel [root@KVM_1 ~]# gem sources --add http://gems.ruby-china.org/ --remove https://gems.ruby-china.org/ [root@KVM_1 ~]# gem sources -l *** CURRENT SOURCES *** http://gems.ruby-china.org/ [root@KVM_1 ~]# [root@KVM_1 ~]# gem install fpm [root@KVM_1 ~]# yum install -y rpm-build

#編譯安裝Nginx

[root@KVM_1 ~]# wget http://mirrors.sohu.com/nginx/nginx-1.13.0.tar.gz [root@KVM_1 ~]# tar -xf nginx-1.13.0.tar.gz  [root@KVM_1 ~]# cd nginx-1.13.0/ [root@KVM_1 nginx-1.13.0]# yum install -y pcre pcre-devel openssl openssl-devel gcc-c++ [root@KVM_1 nginx-1.13.0]# useradd -s /usr/sbin/nologin -M nginx [root@KVM_1 nginx-1.13.0]# ./configure --with-http_stub_status_module --with-http_ssl_module --prefix=/usr/local/nginx  --user=nginx --group=nginx [root@KVM_1 nginx-1.13.0]# make && make install [root@KVM_1 nginx-1.13.0]# cd [root@KVM_1 ~]# /usr/local/nginx/sbin/nginx  [root@KVM_1 ~]# curl -I 192.168.174.134 HTTP/1.1 200 OK Server: nginx/1.13.0 Date: Wed, 10 May 2017 19:52:20 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Wed, 10 May 2017 19:50:48 GMT Connection: keep-alive ETag: "59136f18-264" Accept-Ranges: bytes [root@KVM_1 ~]# /usr/local/nginx/sbin/nginx -s quit

#編寫軟件包安裝后要執(zhí)行的命令的腳本

[root@KVM_1 ~]# cat /root/nginx_init.sh  #!/bin/bash   useradd -s /sbin/nologin -M  nginx  echo '[Unit] Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=network.target remote-fs.target nss-lookup.target   [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true   [Install] WantedBy=multi-user.target ' > /usr/lib/systemd/system/nginx.service [root@KVM_1 ~]#chmod +x /root/nginx_init.sh

#打包rpm

[root@KVM_1 ~]# fpm -s dir -t rpm -n nginx -v 1.13.0 -d 'pcre,pcre-devel,openssl,openssl-devel' --post-install /root/nginx_init.sh -f /usr/local/nginx #參數(shù)解釋 -s 源類型 此處為 目錄 -t 目標(biāo)類型 此處為 rpm -n 軟件包名  此處為 nginx -v 版本號   此處為 1.13.0 -d 依賴包  此處為 pcre,pcre-devel,openssl,openssl-devel --post-install 安裝軟件包后要執(zhí)行的腳本 此處為 /root/nginx_init.sh -f 強(qiáng)制覆蓋 /usr/local/nginx 要被打包的目錄 # #打包完成后會在當(dāng)前目錄生成 rpm包 [root@KVM_1 ~]# ls anaconda-ks.cfg  nginx-1.13.0.tar.gz   nginx_init.sh  nginx-1.13.0  nginx-1.13.0-1.x86_64.rpm

#測試

[root@KVM_1 ~]# hostname KVM_1 [root@KVM_1 ~]# scp nginx-1.13.0-1.x86_64.rpm 192.168.174.135:/media/ [root@KVM_1 ~]# ssh 192.168.174.135 [root@KVM_2 ~]# hostname KVM_2 #配置YUM源 [root@KVM_2  ~]# cat /etc/yum.repos.d/local.repo  [local] name=local baseurl=file:///media/ gpgcheck=0 enabled=1 [root@KVM_2 ~]# mount /dev/cdrom /mnt/ [root@KVM_2 ~]# cp /mnt/* /media/ [root@KVM_2 ~]# cd /media/ #更新YUM倉庫 [root@KVM_2 media]# createrepo -v ./ [root@KVM_2 media]# yum makecache [root@KVM_2 media]# yum list | grep nginx nginx.x86_64                               1.13.0-1                    local    pcp-pmda-nginx.x86_64                      3.10.6-2.el7                local     #安裝nginx [root@KVM_2 media]# yum install -y nginx [root@KVM_2 media]# systemctl start nginx [root@KVM_2 media]# systemctl status nginx ● nginx.service - nginx - high performance web server    Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)    Active: active (running) since Thu 2017-05-11 04:00:07 CST; 12s ago      Docs: http://nginx.org/en/docs/   Process: 4681 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)   Process: 4679 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)  Main PID: 4684 (nginx)    CGroup: /system.slice/nginx.service            ├─4684 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf            └─4685 nginx: worker process May 11 04:00:07 KVM_2 systemd[1]: Starting nginx - high performance web server... May 11 04:00:07 KVM_2 nginx[4679]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok May 11 04:00:07 KVM_2 nginx[4679]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful May 11 04:00:07 KVM_2 systemd[1]: Started nginx - high performance web server. [root@KVM_2 media]# netstat -lntup | grep 80 tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4684/nginx: master   [root@KVM_2 media]# curl -I 192.168.174.135 HTTP/1.1 200 OK Server: nginx/1.13.0 Date: Wed, 10 May 2017 20:01:14 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Wed, 10 May 2017 20:14:24 GMT Connection: keep-alive ETag: "591374a0-264" Accept-Ranges: bytes

#至此nginx FPM 打包完成

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

當(dāng)前標(biāo)題:FPM制作rpm包-創(chuàng)新互聯(lián)
當(dāng)前網(wǎng)址:http://muchs.cn/article22/dpigcc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版微信公眾號、用戶體驗、外貿(mào)網(wǎng)站建設(shè)、云服務(wù)器網(wǎng)站內(nèi)鏈

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)