1. nginx
1.1 rpm-build安装
# 安装rpm-build
yum install -y rpm-build
# 创建目录 (通过报错产生目录)
cd ~; rpmbuild -ba nginx.spec
# 目录结构
tree -n ~/rpmbuild/
/root/rpmbuild/
├── BUILD 配置编译目录
├── BUILDROOT
├── RPMS rpmbuild制作好的二进制包
├── SOURCES 源代码
├── SPECS 管理rpm制作进程的spec文件
└── SRPMS rpmbuild制作好的源码包
# 编写spec文件 (文件内容在2.3章节)
vim ~/rpmbuild/SPECS/nginx.spec
1.2 制作rpm
# centos8 (注意exclude顺序)
tar cvzf nginx-1.22.0.tar.gz \
--exclude nginx-1.22.0/objs --exclude nginx-1.22.0/objs/* \
nginx-1.22.0
# 拷贝tar.gz源代码
mv nginx-1.22.0.tar.gz ~/rpmbuild/SOURCES
# 制作rpm包
rpmbuild -bb ~/rpmbuild/SPECS/nginx.spec
# 查看rpm
ll ~/rpmbuild/RPMS/x86_64/nginx-1.22.0-1.el8.x86_64.rpm
1.3 nginx.spec
Name:nginx
Version:1.22.0
Release: 1%{?dist}
Summary:this is a web server
#Group:
License:GPL
URL:www.abc.com
Source0:nginx-1.22.0.tar.gz
#BuildRequires:
#Requires:
%description
this is a web server
%prep
%setup -q
%build
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx --group=nginx --with-compat --with-file-aio --with-threads \
--with-http_addition_module --with-http_auth_request_module \
--with-http_dav_module --with-http_flv_module --with-http_gunzip_module \
--with-http_gzip_static_module --with-http_mp4_module \
--with-http_random_index_module --with-http_realip_module \
--with-http_secure_link_module --with-http_slice_module \
--with-http_ssl_module --with-http_stub_status_module --with-http_sub_module \
--with-http_v2_module --with-mail --with-mail_ssl_module --with-stream \
--with-stream_realip_module --with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' \
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
make %{?_smp_mflags}
%install
%make_install
make install
%files
%doc
/etc/nginx/*
/usr/sbin/nginx
%changelog
1.4 一键rpm脚本
#!/bin/bash
nginx_src_path="/root/source"
nginx_src_dir_name="nginx-1.22.0"
rpm_path="/root/rpmbuild"
rpm_src_dir_name="SOURCES"
# get src tar.gz
tar cvzf ${rpm_path}/${rpm_src_dir_name}/${nginx_src_dir_name}.tar.gz \
--exclude objs --exclude objs/* \
-C ${nginx_src_path} ${nginx_src_dir_name}
# get rpm
rpmbuild -bb ${rpm_path}/SPECS/nginx.spec
ls -al ${rpm_path}/RPMS/x86_64/${nginx_src_dir_name}-*rpm
2. openresty