Linux学习-制作RPM包

制作nginx的RPM包

安装rpm-build软件
[root@py-redis SPECS]# dnf install -y rpm-build
生成rpmbuild目录结构
[root@py-redis SPECS]# rpmbuild -ba nginx.spec
[root@py-redis SPECS]# ls /root/rpmbuild/
BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS
将源码软件复制到SOURCES目录(本例使用nginx-1.22.1)
[root@py-redis SPECS]# cp ../lnmp_soft/nginx-1.22.1.tar.gz SOURCES/
创建并修改SPEC配置文件
Name:nginx
Version:1.22.1
Release:10
Summary:nginx is a web server software
Group:
License: GPL
URL: www.test.com
Source0:nginx-1.22.1.tar.gz
#BuildRequires: 
Requires:pcre-devel openssl-devel
%description
nginx is an HTTP and reverse proxy server.
%post
useradd nginx
%prep
%setup -q
%build
./configure
make %{?_smp_mflags}
%install
make install DESTDIR=%{buildroot}
%files
%doc
/usr/local/nginx/*
%changelog
用配置文件创建RPM包
[root@py-redis SPECS]# yum install -y pcre-devel gcc make openssl-devel
[root@py-redis SPECS]# rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec 
[root@py-redis SPECS]# ls /root/rpmbuild/RPMS/x86_64/nginx-1.22.1-10.x86_64.rpm 
安装测试
[root@py-redis SPECS]# yum install -y /root/rpmbuild/RPMS/x86_64/nginx-1.22.1-10.x86_64.rpm 
[root@py-redis SPECS]# /usr/local/nginx/sbin/nginx 
[root@py-redis SPECS]# curl 192.168.88.11
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

你可能感兴趣的:(Linux,linux,学习,运维)