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>
  • 6
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Cenos 6.7 x86_64 yum安装 yum localinstal nginx-1.6.3-1.x86_64.rpm 定制安装过程 1: FPM 打工具安装 修改yum源: 备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 安装阿里云yum源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 安装依赖 yum -y install ruby rubygems ruby-devel 添加阿里云的Rubygems 仓库 gem sources -a http://mirrors.aliyun.com/rubygems/ #移除原生Ruby仓库 gem sources --remove http://rubygems.org/ 指定安装版本 gem install fpm -v 1.3.3 wget http://nginx.org/download/nginx-1.9.7.tar.gz wget http://nginx.org/download/nginx-1.6.3.tar.gz mkdir -p /application/tools cd /application/tools/ find /var/cache/yum/ -name "*rpm" yum install pcre-devel openssl-devel find /var/cache/ -type f -name '*rpm' find /var/cache/ -type f -name '*rpm'|xargs cp -t /tmp/ cd /tmp tar zcf nginx_yum.tar.gz *.rpm sz nginx_yum.tar.gz cd /application/tools/ useradd nginx -M -s /sbin/nologin tar zxf nginx-1.6.3.tar.gz ./configure --prefix=/application/nginx-1.6.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module make make install ln -s /application/nginx-1.6.3/ /application/nginx /application/nginx/sbin/nginx ss -lntup|grep nginx ps -ef|grep nginx|grep -v grep netstat -lntup|grep nginx|grep -v grep curl 127.0.0.1 mkdir -p /server/scripts cd /server/scripts/ fpm -s dir -t rpm -n nginx -v 1.6.3 -d 'pcre-devel,openssl-devel' --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.6.3/ 检查 rpm -qpl nginx-1.6.3-1.x86_64.rpm [root@nginx tools]# rpm -qpl nginx-1.6.3-1.x86_64.rpm /application/nginx-1.6.3/client_body_temp /application/nginx-1.6.3/conf/fastcgi.conf /application/nginx-1.6.3/conf/fastcgi.conf.default /application/nginx-1.6.3/conf/fastcgi_params /application/nginx-1.6.3/conf/fastcgi_params.default /application/nginx-1.6.3/conf/koi-utf /application/nginx-1.6.3/conf/koi-win /application/nginx-1.6.3/conf/mime.types /application/nginx-1.6.3/conf/mime.types.default /a
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值