如何製作nginx的RPM包?

以nginx的1.12.2版本爲例
一:首先安裝rpm-build軟件
1:安裝rpm-build的軟件包

[root@~]#yum -y install rpm-build

2:生成rpmbuild的目錄結構

[root@~]#rpmbulid -ba nginx.spec	#會報錯,沒有文件或目錄
[root@~]#ls /root/rpmbuild		#查看自動生成的目錄結構
BUILD BULLDROOT RPMS SOURCES SPECES SRPMS

3:準備工作,將源碼軟件複製到SOURCES目錄

[root@~]#cp nginx-1.12.2.tar.gz /root/rpmbuild/SOURCES/

4:創建SPEC文件

[root@~]# vim /root/rpmbuild/SPECS/nginx.spec 
Name:nginx                                        #源碼包軟件名稱
Version:1.12.2                                    #源碼包軟件的版本號
Release:    10                                        #製作的RPM包版本號
Summary: Nginx is a web server software.            #RPM軟件的概述    
License:GPL                                        #軟件的協議
URL:    www.test.com                                    #網址
Source0:nginx-1.12.2.tar.gz                        #源碼包文件的全稱
#BuildRequires:                                    #製作RPM時的依賴關係
#Requires:                                        #安裝RPM時的依賴關係
%description
nginx [engine x] is an HTTP and reverse proxy server.    #軟件的詳細描述
%post
useradd nginx                               #非必需操作:安裝後腳本(創建賬戶)
%prep
%setup -q                                #自動解壓源碼包,並cd進入目錄
%build
./configure
make %{?_smp_mflags}
%install
make install DESTDIR=%{buildroot}
%files
%doc
/usr/local/nginx/*                    #對哪些文件與目錄打包
%changelog

二:使用配置文件創建RPM包
1:安裝依賴軟件包

[root@~]#yum -y install gcc pcre-devel openssl-devel

2:rpmbuild創建RPM軟件包

[root@~]#rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec
[root@~]#ls /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm

三:安裝軟件

[root@~]#yum install /root/rpmbuild/RPMS/x86_64.rpm
[root@~]#rpm -qa | grep nginx		#查看安裝的nginx軟件版本
[root@~]#ls /usr/local/nginx/		
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章