http://nginx.org/en/download.html
[student@room9pc01 下载]$ pwd
/home/student/下载
[student@room9pc01 下载]$ ls
nginx-1.12.2.tar.gz
yum -y install gcc pcre-devel openssl-devel
useradd -s /sbin/nologin nginx
cd /root/lnmp_soft/
cp -p nginx-1.12.2.tar.gz /root
cd /root/
tar -xf nginx-1.12.2.tar.gz
cd nginx-1.12.2/
./configure
–user=nginx
–group=nginx
–with-stream
–with-http_ssl_module
–with-http_stub_status_module
make&&make install
systemctl stop httpd
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -V
netstat -antulp | grep nginx
[student@room9pc01 ~]$ yum -y install rpm-build #安装rpm-build软件包
[student@room9pc01 ~]$ rpmbuild -ba zhangdong.spec #生成rpmbuild目录结构
[student@room9pc01 ~]$ cd /home/student/rpmbuild/ #家目录下,生成rpmbuild目录结构
[student@room9pc01 rpmbuild]$ ls
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[student@room9pc01 rpmbuild]$ cd SOURCES/
[student@room9pc01 SOURCES]$ cp /linux-soft/02/lnmp_soft/nginx-1.12.2.tar.gz . #####将源码软件复制到SOURCES目录
[student@room9pc01 SOURCES]$ ls
nginx-1.12.2.tar.gz
[student@room9pc01 SOURCES]$ cd …
[student@room9pc01 rpmbuild]$ cd SPECS/
[student@room9pc01 SPECS]$ vim nginx.spec
Name:nginx #源码包软件名称
Version:1.12.2 #源码包软件的版本号
Release:10 #制作的RPM包版本号
Summary:Nginx is a web server software. #RPM软件的概述
#Group:
License:GPL #软件的协议
URL:www.nginx.org #网址
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 --user=nginx --group=nginx --with-stream --with-http_ssl_module --with-http_stub_status_module ##配置
make %{?_smp_mflags} #编译
%install
make install DESTDIR=%{buildroot} ##安装
%files
%doc
/usr/local/nginx/* #对哪些文件与目录打包
%changelog
[student@room9pc01 SPECS]$ yum -y install gcc pcre-devel openssl-devel ### 安装依赖
[student@room9pc01 SPECS]$ rpmbuild -ba /home/student/rpmbuild/SPECS/nginx.spec ##生成RPM包
[student@room9pc01 SPECS]$ cd …
[student@room9pc01 rpmbuild]$ cd RPMS/
[student@room9pc01 RPMS]$ cd x86_64/
[student@room9pc01 x86_64]$ ls
nginx-1.12.2-10.x86_64.rpm nginx-debuginfo-1.12.2-10.x86_64.rpm ###生成rpm包位置