安装制作软件:
yum -y install rpm-build
[root@lv1 ~]# ls /root/rpmbuild/
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
把源码包,拷贝到该目录下:
cp nginx-1.12.2.tar.gz /root/rpmbuild/SOURCES/
vim /root/rpmbuild/SPECS/nginx.spec
Name:nginx
Version:1.12.2
Release: 10
Summary:Nginx is a web server software.
#Group:
License:GPL
URL: www.test.com
Source0:nginx-1.12.2.tar.gz
#BuildRequires:
#Requires:
scription
nginx [engine x] is an HTTP and reverse proxy server.
%prep
%setup -q
//自动解压源码包,并cd进入目录
%build
./configure
make %{?_smp_mflags}
%install
make install DESTDIR=%{buildroot}
%files
%doc
/usr/local/nginx/*
//对哪些文件与目录打包
%changelog
安装相关的依赖包:
yum -y install gcc pcre-devel zlib-devel openssl-devel
打包源码包:
rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec
查看已经打包的rpm包:
[root@lv1 ~]# ls /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm
/root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm
查看已经打包的rpm包的基本信息:
[root@lv1 ~]# rpm -qpi /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm
Name : nginx
Version : 1.12.2
Release : 10
Architecture: x86_64
Install Date: (not installed)
Group : Unspecified
Size : 739541
License : GPL
Signature : (none)
Source RPM : nginx-1.12.2-10.src.rpm
Build Date : 2018年08月30日 星期四 15时42分22秒
Build Host : lv1
Relocations : (not relocatable)
URL : www.test.com
Summary : Nginx is a web server software.
Description :
nginx [engine x] is an HTTP and reverse proxy server
rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec
查看rpm的相关的配置参数:
[root@lv1 ~]# rpm -qpl /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm
/usr/local/nginx/conf
/usr/local/nginx/conf/fastcgi.conf
/usr/local/nginx/conf/fastcgi.conf.default
/usr/local/nginx/conf/fastcgi_params
/usr/local/nginx/conf/fastcgi_params.default
/usr/local/nginx/conf/koi-utf
/usr/local/nginx/conf/koi-win
/usr/local/nginx/conf/mime.types
/usr/local/nginx/conf/mime.types.default
/usr/local/nginx/conf/nginx.conf
/usr/local/nginx/conf/nginx.conf.default
/usr/local/nginx/conf/scgi_params
/usr/local/nginx/conf/scgi_params.default
/usr/local/nginx/conf/uwsgi_params
/usr/local/nginx/conf/uwsgi_params.default
/usr/local/nginx/conf/win-utf
/usr/local/nginx/html
/usr/local/nginx/html/50x.html
/usr/local/nginx/html/index.html
/usr/local/nginx/logs
/usr/local/nginx/sbin
/usr/local/nginx/sbin/nginx
安装打包的rpm包:
[root@lv1 ~]# rpm -ivh /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:nginx-1.12.2-10 ################################# [100%]
[root@lv1 ~]# rpm -qa | grep nginx
nginx-1.12.2-10.x86_64
检查nginx是否已经安装:
rpm -qa | grep nginx
启动nginx的服务:
/usr/local/nginx/sbin/nginx
##如果有httpd暂用了80端口需要关闭: systemctl stop httpd
访问本机的web页面:
curl http://127.0.0.1