Skip to content

Commit

Permalink
[Update]更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Administrator committed Apr 12, 2020
1 parent cd1882b commit 3d5a222
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 1 deletion.
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
# tengine-rpm
# tengine-rpm

生成 tengine 的安装包, spec 文件从 nginx rpm 源文件获取并修改

Use:
```
$ cd /tmp
$ git clone https://github.com/wojiushixiaobai/tengine-rpm.git
$ cd tngine-rpm
# 自行编辑 build_tengine.sh 和 tengine.spec
$ sh build_tengine.sh
```

Install:
```
yum localinstall tengine-2.3.2-1.el7.ngx.x86_64.rpm
```

Uninstall
```
yum remove tengine
```

Start
```
systemctl start nginx
```

Stop
```
systemctl stop nginx
```

Restart
```
systemctl restart nginx
```

项目参考了 [Axizdkr](https://github.com/Axizdkr/tengine/blob/master/Dockerfile) configure

spec 为直接修改 [Nginx](http://nginx.org/) 源 rpm 包
89 changes: 89 additions & 0 deletions build_tengine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
#

tengine_version=tengine-2.3.2
BASE_DIR=$(cd "$(dirname "$0")";pwd)
PROJECT_DIR=${BASE_DIR}

cd ~

which wget >/dev/null 2>&1
if [ $? -ne 0 ];then
yum install -y wget
fi
if [ ! "$(rpm -qa | grep epel-release)" ]; then
yum install -y epel-release
fi
if grep -q 'mirrors.aliyun.com' /etc/yum.repos.d/CentOS-Base.repo; then
true
else
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
fi

if [ ! "$(rpm -qa | grep gcc-c++)" ]; then
yum install -y gcc-c++ pcre-devel openssl-devel
fi

if [ ! -d "$tengine_version" ]; then
wget http://tengine.taobao.org/download/${tengine_version}.tar.gz
tar -xf ${tengine_version}.tar.gz
wget https://github.com/openresty/headers-more-nginx-module/archive/v0.33.tar.gz
tar -xf v0.33.tar.gz -C ${tengine_version}/modules
rm -rf ${tengine_version}.tar.gz v0.33.tar.gz
fi

cd ${tengine_version}

./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' --add-module=modules/ngx_http_upstream_check_module --add-module=modules/headers-more-nginx-module-0.33 --add-module=modules/ngx_http_upstream_session_sticky_module

make -j$(getconf _NPROCESSORS_ONLN)
cd objs

if [ ! -f nginx.8.gz ]; then
gzip nginx.8
fi

if [ ! "$(rpm -qa | grep rpmrebuild)" ]; then
yum install -y rpm-build rpmrebuild rpm cpio
fi

if [ ! -d "~/rpmbuild" ]; then
mkdir -p ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64 ~/rpmbuild/SPECS
fi

cd ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64
wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.16.1-1.el7.ngx.x86_64.rpm
rpm2cpio nginx-1.16.1-1.el7.ngx.x86_64.rpm | cpio -div
rm -rf nginx-1.16.1-1.el7.ngx.x86_64.rpm

rm -rf ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/usr/sbin/nginx
cp ~/${tengine_version}/objs/nginx ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/usr/sbin/

rm -rf ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/etc/nginx/fastcgi.conf
cp ~/${tengine_version}/conf/fastcgi.conf ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/etc/nginx/

rm -rf ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/usr/share/man/man8/nginx.8.gz
mv ~/${tengine_version}/objs/nginx.8.gz ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/usr/share/man/man8/

rm -rf ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/etc/sysconfig/nginx-debug
rm -rf ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/usr/sbin/nginx-debug
rm -rf ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/usr/share/doc/

sed -i "s/worker_processes 1;/worker_processes auto;/g" ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/etc/nginx/nginx.conf
sed -i "s/Description=nginx/Description=tengine/g" ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/usr/lib/systemd/system/nginx.service
sed -i "s@http://nginx.org/en/docs/@http://tengine.taobao.org/@g" ~/rpmbuild/BUILDROOT/${tengine_version}-1.el7.ngx.x86_64/usr/lib/systemd/system/nginx.service

cd ~/rpmbuild/SPECS
if [ ! -f "tengine.spec" ]; then
cp $PROJECT_DIR/tengine.spec ./
fi

cd ~/rpmbuild
rpmbuild -bb SPECS/tengine.spec

rm -rf ~/${tengine_version}

mv ~/rpmbuild/RPMS/x86_64/${tengine_version}-1.el7.ngx.x86_64.rpm ~/

echo "执行 yum localinstall ~/${tengine_version}-1.el7.ngx.x86_64.rpm 安装 tengine"
186 changes: 186 additions & 0 deletions tengine.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# rpmrebuild autogenerated specfile

BuildRoot: /root/.tmp/rpmrebuild.1751/work/root
AutoProv: no
%undefine __find_provides
AutoReq: no
%undefine __find_requires
# Do not try autogenerate prereq/conflicts/obsoletes and check files
%undefine __check_files
%undefine __find_prereq
%undefine __find_conflicts
%undefine __find_obsoletes
# Be sure buildpolicy set to do nothing
%define __spec_install_post %{nil}
# Something that need for rpm-4.1
%define _missing_doc_files_terminate_build 0
#dummy
#dummy
#BUILDHOST: centos74-amd64-builder-builder.gnt.nginx.com
#BUILDTIME: Tue Aug 13 23:04:33 2019
#SOURCERPM: nginx-1.17.3-1.el7.ngx.src.rpm

#RPMVERSION: 4.11.3
#COOKIE: centos74-amd64-builder-builder.gnt.nginx.com 1565708673


#OS: linux
#SIZE: 2811768
#ARCHIVESIZE: 2816552
#ARCH: x86_64
BuildArch: x86_64
Name: tengine
Version: 2.3.2
Release: 1.el7.ngx
License: 2-clause BSD-like license
Group: System Environment/Daemons
Summary: High performance web server


URL: http://tengine.taobao.org/
Vendor: Nginx, Inc.

Epoch: 1




Provides: config(tengine) = 1:2.3.2-1.el7.ngx
Provides: tengine = 1:2.3.2-1.el7.ngx
Provides: tengine(x86-64) = 1:2.3.2-1.el7.ngx
Provides: webserver
Requires: /bin/sh
Requires: /bin/sh
Requires: /bin/sh
Requires: /bin/sh
Requires: /bin/sh
Requires: config(tengine) = 1:2.3.2-1.el7.ngx
Requires: libc.so.6()(64bit)
Requires: libc.so.6(GLIBC_2.10)(64bit)
Requires: libc.so.6(GLIBC_2.14)(64bit)
Requires: libc.so.6(GLIBC_2.17)(64bit)
Requires: libc.so.6(GLIBC_2.2.5)(64bit)
Requires: libc.so.6(GLIBC_2.3)(64bit)
Requires: libc.so.6(GLIBC_2.3.2)(64bit)
Requires: libc.so.6(GLIBC_2.3.4)(64bit)
Requires: libc.so.6(GLIBC_2.4)(64bit)
Requires: libc.so.6(GLIBC_2.7)(64bit)
Requires: libcrypt.so.1()(64bit)
Requires: libcrypt.so.1(GLIBC_2.2.5)(64bit)
Requires: libcrypto.so.10()(64bit)
Requires: libcrypto.so.10(OPENSSL_1.0.2)(64bit)
Requires: libcrypto.so.10(libcrypto.so.10)(64bit)
Requires: libdl.so.2()(64bit)
Requires: libdl.so.2(GLIBC_2.2.5)(64bit)
Requires: libpcre.so.1()(64bit)
Requires: libpthread.so.0()(64bit)
Requires: libpthread.so.0(GLIBC_2.2.5)(64bit)
Requires: libpthread.so.0(GLIBC_2.3.2)(64bit)
Requires: libssl.so.10()(64bit)
Requires: libssl.so.10(libssl.so.10)(64bit)
Requires: libz.so.1()(64bit)
Requires: openssl >= 1.0.2
#Requires: rpmlib(CompressedFileNames) <= 3.0.4-1
#Requires: rpmlib(FileDigests) <= 4.6.0-1
#Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: rtld(GNU_HASH)
Requires: shadow-utils
Requires: systemd
Requires: systemd
Requires: systemd
#Requires: rpmlib(PayloadIsXz) <= 5.2-1
#suggest
#enhance
%description
nginx [engine x] is an HTTP and reverse proxy server, as well as
a mail proxy server.
%files
%config(noreplace) %attr(0644, root, root) "/etc/logrotate.d/nginx"
%dir %attr(0755, root, root) "/etc/nginx"
%dir %attr(0755, root, root) "/etc/nginx/conf.d"
%config(noreplace) %attr(0644, root, root) "/etc/nginx/conf.d/default.conf"
%config(noreplace) %attr(0644, root, root) "/etc/nginx/fastcgi_params"
%config(noreplace) %attr(0644, root, root) "/etc/nginx/koi-utf"
%config(noreplace) %attr(0644, root, root) "/etc/nginx/koi-win"
%config(noreplace) %attr(0644, root, root) "/etc/nginx/mime.types"
%attr(0777, root, root) "/etc/nginx/modules"
%config(noreplace) %attr(0644, root, root) "/etc/nginx/nginx.conf"
%config(noreplace) %attr(0644, root, root) "/etc/nginx/scgi_params"
%config(noreplace) %attr(0644, root, root) "/etc/nginx/uwsgi_params"
%config(noreplace) %attr(0644, root, root) "/etc/nginx/win-utf"
%config(noreplace) %attr(0644, root, root) "/etc/sysconfig/nginx"
%attr(0644, root, root) "/usr/lib/systemd/system/nginx.service"
%dir %attr(0755, root, root) "/usr/lib64/nginx"
%dir %attr(0755, root, root) "/usr/lib64/nginx/modules"
%dir %attr(0755, root, root) "/usr/libexec/initscripts/legacy-actions/nginx"
%attr(0755, root, root) "/usr/libexec/initscripts/legacy-actions/nginx/check-reload"
%attr(0755, root, root) "/usr/libexec/initscripts/legacy-actions/nginx/upgrade"
%attr(0755, root, root) "/usr/sbin/nginx"
%doc %attr(0644, root, root) "/usr/share/man/man8/nginx.8.gz"
%dir %attr(0755, root, root) "/usr/share/nginx"
%dir %attr(0755, root, root) "/usr/share/nginx/html"
%attr(0644, root, root) "/usr/share/nginx/html/50x.html"
%attr(0644, root, root) "/usr/share/nginx/html/index.html"
%dir %attr(0755, root, root) "/var/cache/nginx"
%dir %attr(0755, root, root) "/var/log/nginx"
%pre -p /bin/sh
# Add the "nginx" user
getent group nginx >/dev/null || groupadd -r nginx
getent passwd nginx >/dev/null || \
useradd -r -g nginx -s /sbin/nologin \
-d /var/cache/nginx -c "nginx user" nginx
exit 0
%post -p /bin/sh
# Register the nginx service
if [ $1 -eq 1 ]; then
/usr/bin/systemctl preset nginx.service >/dev/null 2>&1 ||:
# print site info
cat <<BANNER
----------------------------------------------------------------------
Welcome to tengine!
If you see this page, the tengine web server is successfully installed and
working. Further configuration is required.
For online documentation and support please refer to:
* http://tengine.taobao.org/
Thank you for using tengine.
----------------------------------------------------------------------
BANNER

# Touch and set permisions on default log files on installation

if [ -d /var/log/nginx ]; then
if [ ! -e /var/log/nginx/access.log ]; then
touch /var/log/nginx/access.log
/usr/bin/chmod 640 /var/log/nginx/access.log
/usr/bin/chown nginx:adm /var/log/nginx/access.log
fi

if [ ! -e /var/log/nginx/error.log ]; then
touch /var/log/nginx/error.log
/usr/bin/chmod 640 /var/log/nginx/error.log
/usr/bin/chown nginx:adm /var/log/nginx/error.log
fi
fi
fi
%preun -p /bin/sh
if [ $1 -eq 0 ]; then
/usr/bin/systemctl --no-reload disable nginx.service >/dev/null 2>&1 ||:
/usr/bin/systemctl stop nginx.service >/dev/null 2>&1 ||:
fi
%postun -p /bin/sh
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
if [ $1 -ge 1 ]; then
/sbin/service nginx status >/dev/null 2>&1 || exit 0
/sbin/service nginx upgrade >/dev/null 2>&1 || echo \
"Binary upgrade failed, please check nginx's error.log"
fi
%changelog
* Tue Aug 20 2019 Yuhuang Wu <[email protected]>
- 2.3.2
- Initial release

0 comments on commit 3d5a222

Please sign in to comment.