關(guān)于nginx的rpm包的制作

  1. 準(zhǔn)備安裝包環(huán)境

yum install   make gcc gcc-c++ openssl openssl-devel pcre-devel zlib-devel rpm-build-4.11.3-48.el7_9.x86_64  rpmlint.noarch -y

wget http://nginx.org/download/nginx-1.22.1.tar.gz

  1. 準(zhǔn)備制作RPM包目錄

mkdir -p ~/rpmbuild/SOURCES

cp  nginx-1.22.1.tar.gz   ~/rpmbuild/SOURCES

  1. 目錄結(jié)構(gòu)

[root@iZ0jl7nhcg5nazteof1pt3Z ~]# tree -L 3

.

└── rpmbuild

    ├── BUILD

    │   └── nginx-1.22.1

    ├── BUILDROOT

    ├── RPMS

    │   └── x86_64

    ├── SOURCES

    │   └── nginx-1.22.1.tar.gz

    ├── SPECS

    │   ├── nginx.spec

    │   └── nginx.spec.bak

    └── SRPMS

4 nginx.spec文件


Summary: High Performance Web Server

Name: nginx

Version: 1.22.1

Release: el7

License: GPL

Group: Applications/Server

Source: nginx-1.22.1.tar.gz

URL: http://nginx.org/

Distribution: Linux

Packager: qiao <181864031@qq.com>

BuildRoot: root/nginx-1.22.1-el7

BuildRequires: gcc,gcc-c++,pcre-devel,zlib-devel

%description

nginx [engine x] is a HTTP and reverse proxy server, as well as a mail proxy server

%post

id nginx &>/dev/null

if [ $? -ne 0 ];

then

  useradd nginx

fi

echo "export PATH=/usr/local/nginx/sbin:$PATH" >> /etc/profile

source /etc/profile

declare -a filePaths

filePaths=(/var/log/nginx  /var/run  /var/cache/nginx)

for i in ${filePaths[*]}

do

        if [ ! -d ${i} ];

        then

                mkdir  ${i}

        fi

done

%preun

userdel -r nginx

%prep

%setup -q

%build

./configure \

--prefix=/usr/local/nginx \

--user=nginx \

--group=nginx \

--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 \

--modules-path=/usr/lib64/nginx/modules \

--sbin-path=/usr/local/nginx/sbin/nginx \

--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 \

--with-http_ssl_module \

--with-http_realip_module \

--with-http_addition_module \

--with-http_sub_module \

--with-http_dav_module \

--with-http_flv_module \

--with-http_mp4_module \

--with-http_gunzip_module \

--with-http_gzip_static_module \

--with-http_random_index_module \

--with-http_secure_link_module \

--with-http_stub_status_module \

--with-http_auth_request_module \

--with-mail \

--with-mail_ssl_module \

--with-file-aio \

--with-ipv6 \

--with-stream

make %{?_smp_mflags}

%install

make install DESTDIR=%{buildroot}

%files

/usr/local/nginx

/etc/nginx

5.檢查語法


[root@iZ0jl7nhcg5nazteof1pt3Z SPECS]# rpmlint nginx.spec

nginx.spec:6: W: non-standard-group Applications/Server

nginx.spec:37: W: configure-without-libdir-spec

nginx.spec: W: invalid-url Source0: nginx-1.22.1.tar.gz

0 packages and 1 specfiles checked; 0 errors, 3 warnings.

[root@iZ0jl7nhcg5nazteof1pt3Z SPECS]#



6.生成rpm包


rpmbuild -bb nginx.spec

7安裝包位置


── RPMS

│   └── x86_64

│      ├── nginx-1.22.1-el7.x86_64.rpm

│      └── nginx-debuginfo-1.22.1-el7.x86_64.rpm

├── SOURCES

│   └── nginx-1.22.1.tar.gz

├── SPECS

│   ├── nginx.spec

│   └── nginx.spec.bak

└── SRPMS

8.安裝nginx


rpm -ivh nginx-1.22.1-el7.x86_64.rpm

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容