暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Nginx arm编译安装

济南小老虎 2023-07-17
57

背景

计划编译一套产品. 能够比较方便快捷的进行 nginx的交付. 

主要思想是源码编译 不仅能够在arm上面运行 也可以在x86上面编译
考虑性能还有一些扩展性. 高效处理.

主要涉及的点有:
openssl 最新的1.1.1的的版本
zlib 进行压缩, 解压缩的处理.
pcre 正则相关表达式
check 模块.
nginx 的stream 以及 stream_ssl_preread_module 等模块.

因为暂时不需要考虑粘性, 所以sticky和ip_hash部分暂时不涉及.

复制

文件准备

nginx-1.24.0.tar.gz
nginx-1.25.1.tar.gz
nginx_upstream_check_module-0.4.0.tar.gz
openssl-1.1.1u.tar.gz
pcre-8.45.tar.gz
zlib-1.2.13.tar.gz

复制

解压缩准备编译

for i in `ls` ; do tar -zxvf $i ; done

需要先安装一下组件:
yum install -y gcc-c++

配置的处理方式为:
./configure --prefix=/opt/nginx \
--sbin-path=/opt/nginx/nginx \
--conf-path=/opt/nginx/nginx.conf \
--pid-path=/opt/nginx/nginx.pid \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-stream --with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-http_ssl_module \
--with-pcre=../pcre-8.45 \
--with-zlib=../zlib-1.2.13 \
--with-openssl=../openssl-1.1.1u \
--add-module=../nginx_upstream_check_module-0.4.0

鲲鹏上面make大约耗时3min45s

复制

其他版本的处理

比如我想编译nginx1.25.1

在同一个目录下面的 进入到 nginx-1.25.1

./configure --prefix=/opt/nginx1.25.1 \
--sbin-path=/opt/nginx1.25.1/nginx \
--conf-path=/opt/nginx1.25.1/nginx.conf \
--pid-path=/opt/nginx1.25.1/nginx.pid \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-stream --with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-http_ssl_module \
--with-pcre=../pcre-8.45 \
--with-zlib=../zlib-1.2.13 \
--with-openssl=../openssl-1.1.1u \
--add-module=../nginx_upstream_check_module-0.4.0

# 直接make和make install 就可以了.
耗时3min53s

复制

可以直接上海光进行验证

发现 航芯院的海光make速度长达十分钟. 
是鲲鹏ARM 编译速度的 2.5倍.

华云的安超云OS 的虚拟化水平应该比华为云的虚拟化要虚弱不少.

复制

设置默认页面

很多产品里面 默认会有一个默认页面. 
让大家登录或者是注册.
如果没有设置, 那么进入域名或者是其他地方,可能就会提示 404 或者是nginx的欢迎页面了

最简单的方式其实有两种:
1. 直接将登录注册界面设置到 = 的location的proxy_pass配置节中.
2. 新增一个html 页面, 也是使用 = / 进行 root 设置 index.html 设置, 可以点击勾选跳转到不同的url

复制


文章转载自济南小老虎,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论